diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 935672724c..6c24ee6342 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,7 +67,7 @@ jobs: GOOS: linux GOARCH: ${{ env.CPU_ARCH }} run: | - make install-testnet + make install cp "$HOME"/go/bin/* ./ chmod a+x ./zetacored ./zetacored version diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 090108f3fa..0b3917dead 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,7 +19,7 @@ env: - CC_linux_amd64=x86_64-linux-gnu-gcc - CXX_linux_amd64=x86_64-linux-gnu-g++ - CC_windows_amd64=x86_64-w64-mingw32-gcc - - CXX_windows_amd64=x86_64-w64-mingw32-g++ + - CXX_windows_amd64=x86_64-w64-mingw32-g++ - VERSION={{ .Version }} - COMMIT={{ .Commit }} - BUILDTIME={{ .Date }} @@ -32,9 +32,9 @@ before: - go mod tidy builds: - - id: "zetacored_testnet" + - id: "zetacored" main: ./cmd/zetacored - binary: "zetacored_testnet-{{ .Os }}-{{ .Arch }}" + binary: "zetacored-{{ .Os }}-{{ .Arch }}" env: - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' @@ -48,9 +48,8 @@ builds: ignore: - goos: windows goarch: arm64 - flags: &default_testnet_flags - - -tags=TESTNET,pebbledb,ledger,cgo,netgo - - -installsuffix=static + flags: &default_flags + - -tags=pebbledb,ledger ldflags: &default_ldflags - -X github.com/cosmos/cosmos-sdk/version.Name=zetacore - -X github.com/cosmos/cosmos-sdk/version.ServerName=zetacored @@ -61,11 +60,11 @@ builds: - -X github.com/zeta-chain/zetacore/common.Version={{ .Version }} - -X github.com/zeta-chain/zetacore/common.CommitHash={{ .Env.COMMIT }} - -X github.com/zeta-chain/zetacore/common.BuildTime=={{ .Env.BUILDTIME }} - - -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb + - -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb - - id: "zetaclientd_testnet" + - id: "zetaclientd" main: ./cmd/zetaclientd - binary: "zetaclientd_testnet-{{ .Os }}-{{ .Arch }}" + binary: "zetaclientd-{{ .Os }}-{{ .Arch }}" env: - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' @@ -79,88 +78,9 @@ builds: ignore: - goos: windows goarch: arm64 - flags: *default_testnet_flags + flags: *default_flags ldflags: *default_ldflags - - id: "zetacored_mock_mainnet" - main: ./cmd/zetacored - binary: "zetacored_mock_mainnet-{{ .Os }}-{{ .Arch }}" - env: - - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' - goos: - - linux - - darwin - - windows - goarch: - - arm64 - - amd64 - ignore: - - goos: windows - goarch: arm64 - flags: &default_mock_mainnet_flags - - -tags=MOCK_MAINNET,pebbledb,ledger,cgo - ldflags: *default_ldflags - - - id: "zetaclientd_mock_mainnet" - main: ./cmd/zetaclientd - binary: "zetaclientd_mock_mainnet-{{ .Os }}-{{ .Arch }}" - env: - - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' - goos: - - linux - # - darwin - # - windows - goarch: - - arm64 - - amd64 - ignore: - - goos: windows - goarch: arm64 - flags: *default_mock_mainnet_flags - ldflags: *default_ldflags - - - id: "zetacored_mainnet" - main: ./cmd/zetacored - binary: "zetacored_mainnet-{{ .Os }}-{{ .Arch }}" - env: - - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' - goos: - - linux - - darwin - - windows - goarch: - - arm64 - - amd64 - ignore: - - goos: windows - goarch: arm64 - flags: &default_mainnet_flags - - -tags=pebbledb,ledger,cgo - ldflags: *default_ldflags - - - id: "zetaclientd_mainnet" - main: ./cmd/zetaclientd - binary: "zetaclientd_mainnet-{{ .Os }}-{{ .Arch }}" - env: - - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' - - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' - goos: - - linux - # - darwin - # - windows - goarch: - - arm64 - - amd64 - ignore: - - goos: windows - goarch: arm64 - flags: *default_mainnet_flags - ldflags: *default_ldflags - - archives: - format: binary name_template: "{{ .Binary }}" diff --git a/Dockerfile-versioned-source b/Dockerfile-versioned-source new file mode 100644 index 0000000000..a0ee08a782 --- /dev/null +++ b/Dockerfile-versioned-source @@ -0,0 +1,72 @@ +FROM golang:1.19-alpine + +ENV GOPATH /go +ENV GOOS=linux +ENV CGO_ENABLED=1 + +ARG old_version + +RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux +RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N "" + +WORKDIR /go/delivery/zeta-node + +RUN mkdir -p $GOPATH/bin/old +RUN mkdir -p $GOPATH/bin/new + +ENV NEW_VERSION=v42.0.0 + +# Build new release from the current source +COPY go.mod /go/delivery/zeta-node/ +COPY go.sum /go/delivery/zeta-node/ +RUN cd /go/delivery/zeta-node/ && go mod download +COPY . /go/delivery/zeta-node/ +RUN cd /go/delivery/zeta-node/ && make install +RUN cd /go/delivery/zeta-node/ && make install-smoketest +RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/ +RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/ +RUN cp $GOPATH/bin/smoketest $GOPATH/bin/new/ + +# Checkout and build old binary +RUN git clone https://github.com/zeta-chain/node.git +RUN cd node && git fetch + +RUN cd node && git checkout ${old_version} +RUN cd node && make install +RUN cd node && make install-smoketest +RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/ +RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/ +RUN cp $GOPATH/bin/smoketest $GOPATH/bin/old/ + +RUN git clone https://github.com/zeta-chain/cosmos-sdk.git +RUN cd cosmos-sdk && git checkout zetavisor-v0.1.5 +RUN cd cosmos-sdk/cosmovisor && make zetavisor +# +#FROM golang:1.19-alpine + +#RUN apk --no-cache add openssh jq tmux vim curl bash +RUN ssh-keygen -A +WORKDIR /root + +RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys + +RUN cp /go/bin/zetaclientd /usr/local/bin +RUN cp /go/bin/zetacored /usr/local/bin +RUN cp /go/bin/smoketest /usr/local/bin +RUN cp /go/bin/zetavisor /usr/local/bin + +COPY contrib/localnet/scripts /root +COPY contrib/localnet/preparams /root/preparams +COPY contrib/localnet/ssh_config /root/.ssh/config +COPY contrib/localnet/zetacored /root/zetacored +COPY contrib/localnet/tss /root/tss + +RUN chmod 755 /root/*.sh +RUN chmod 700 /root/.ssh +RUN chmod 600 /root/.ssh/* + +WORKDIR /usr/local/bin +ENV SHELL /bin/sh +EXPOSE 22 + +ENTRYPOINT ["/usr/sbin/sshd", "-D"] diff --git a/Makefile b/Makefile index 121d55c079..2c63c90242 100644 --- a/Makefile +++ b/Makefile @@ -18,14 +18,11 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=zetacore \ -X github.com/zeta-chain/zetacore/common.BuildTime=$(BUILDTIME) \ -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -BUILD_FLAGS := -ldflags '$(ldflags)' -tags PRIVNET,pebbledb,ledger -TESTNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags TESTNET,pebbledb,ledger -MOCK_MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags MOCK_MAINNET,pebbledb,ledger -MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger +BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger TEST_DIR?="./..." -TEST_BUILD_FLAGS := -tags TESTNET,pebbledb,ledger -PRIV_BUILD_FLAGS := -tags PRIVNET,pebbledb,ledger +TEST_BUILD_FLAGS := -tags pebbledb,ledger +HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test clean: clean-binaries clean-dir clean-test-dir clean-coverage @@ -39,6 +36,22 @@ clean-dir: all: install +go.sum: go.mod + @echo "--> Ensure dependencies have not been modified" + GO111MODULE=on go mod verify + +############################################################################### +### Test commands ### +############################################################################### + +run-test: + @go test ${TEST_BUILD_FLAGS} ${TEST_DIR} + +test :clean-test-dir run-test + +test-hsm: + @go test ${HSM_BUILD_FLAGS} ${TEST_DIR} + test-coverage-exclude-core: @go test ${TEST_BUILD_FLAGS} -v -coverprofile coverage.out $(go list ./... | grep -v /x/zetacore/) @@ -57,21 +70,9 @@ clean-test-dir: @rm -rf x/crosschain/client/querytests/.zetacored @rm -rf x/observer/client/querytests/.zetacored -run-test: - @go test ${TEST_BUILD_FLAGS} ${TEST_DIR} - -test :clean-test-dir run-test - -test-priv: - @go test ${PRIV_BUILD_FLAGS} ${TEST_DIR} - -gosec: - gosec -exclude-dir=localnet ./... - -install-testnet: go.sum - @echo "--> Installing zetacored & zetaclientd" - @go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored - @go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetaclientd +############################################################################### +### Install commands ### +############################################################################### build-testnet-ubuntu: go.sum docker build -t zetacore-ubuntu --platform linux/amd64 -f ./Dockerfile-athens3-ubuntu . @@ -85,44 +86,26 @@ install: go.sum @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd -install-mainnet: go.sum - @echo "--> Installing zetacored & zetaclientd" - @go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetacored - @go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetaclientd - -install-mock-mainnet: go.sum - @echo "--> Installing zetacored & zetaclientd" - @go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetacored - @go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetaclientd - - install-zetaclient: go.sum @echo "--> Installing zetaclientd" @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd -# running with race detector on will be slow -install-zetaclient-race-test-only-build: go.sum - @echo "--> Installing zetaclientd" - @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd - install-zetacore: go.sum @echo "--> Installing zetacored" @go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored -install-zetacore-testnet: go.sum - @echo "--> Installing zetacored" - @go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored +# running with race detector on will be slow +install-zetaclient-race-test-only-build: go.sum + @echo "--> Installing zetaclientd" + @go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd install-smoketest: go.sum @echo "--> Installing orchestrator" @go install -mod=readonly $(BUILD_FLAGS) ./contrib/localnet/orchestrator/smoketest -go.sum: go.mod - @echo "--> Ensure dependencies have not been modified" - GO111MODULE=on go mod verify - -test-cctx: - ./standalone-network/cctx-creator.sh +############################################################################### +### Local network ### +############################################################################### init: ./standalone-network/init.sh @@ -136,12 +119,12 @@ chain-stop: @killall zetacored @killall tail +test-cctx: + ./standalone-network/cctx-creator.sh -chain-init-testnet: clean install-zetacore-testnet init -chain-run-testnet: clean install-zetacore-testnet init run - -chain-init-mock-mainnet: clean install-mock-mainnet init -chain-run-mock-mainnet: clean install-mock-mainnet init run +############################################################################### +### Linting ### +############################################################################### lint-pre: @test -z $(gofmt -l .) @@ -153,6 +136,13 @@ lint: lint-pre lint-cosmos-gosec: @bash ./scripts/cosmos-gosec.sh +gosec: + gosec -exclude-dir=localnet ./... + +############################################################################### +### Generation commands ### +############################################################################### + proto: @echo "--> Removing old Go types " @find . -name '*.pb.go' -type f -delete @@ -193,7 +183,7 @@ generate: proto openapi specs typescript docs-zetacored .PHONY: generate ############################################################################### -### Docker Images ### +### Smoke tests ### ############################################################################### zetanode: @@ -237,13 +227,19 @@ stateful-upgrade: $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild . cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d +stateful-upgrade-source: + @echo "--> Starting stateful smoketest" + $(DOCKER) build --build-arg old_version=v10.1.7 -t zetanode -f ./Dockerfile-versioned-source . + $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild . + cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d + stop-stateful-upgrade: cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans - ############################################################################### ### GoReleaser ### ############################################################################### + PACKAGE_NAME := github.com/zeta-chain/node GOLANG_CROSS_VERSION ?= v1.20 GOPATH ?= '$(HOME)/go' diff --git a/app/app.go b/app/app.go index fdcd402ed8..c401b2f243 100644 --- a/app/app.go +++ b/app/app.go @@ -332,6 +332,7 @@ func New( keys[zetaObserverModuleTypes.MemStoreKey], app.GetSubspace(zetaObserverModuleTypes.ModuleName), &stakingKeeper, + app.SlashingKeeper, ) // register the staking hooks diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 18a8ae1f62..f3065fa394 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -8,7 +8,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -const releaseVersion = "v10.1.0" +const releaseVersion = "v11.0.0" func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { diff --git a/changelog.md b/changelog.md index 91e046ae20..3325a4ee69 100644 --- a/changelog.md +++ b/changelog.md @@ -1,45 +1,83 @@ # CHANGELOG +## v11.0.0 + +### Features +* [1387](https://github.com/zeta-chain/node/pull/1387) - Add HSM capability for zetaclient hot key +* add a new thread to zetaclient which checks zeta supply in all connected chains in every block +* add a new tx to update an observer, this can be either be run a tombstoned observer/validator or via admin_policy_group_2. + +### Fixes +* 1b8fdd3394c35afa47e830a5858b3c5c133fad8e - Added check for redeployment of gas and asset token contracts +* [1372](https://github.com/zeta-chain/node/pull/1372) - Include Event Index as part for inbound tx digest +* [1367](https://github.com/zeta-chain/node/pull/1367) - fix minRelayTxFee issue and check misuse of bitcoin mainnet/testnet addresses +* [1358](https://github.com/zeta-chain/node/pull/1358) - add a new thread to zetaclient which checks zeta supply in all connected chains in every block +* prevent deposits for paused zrc20 +* [1406](https://github.com/zeta-chain/node/pull/1406) - improve log prints and speed up evm outtx inclusion +* fix Athens-3 issue - include bitcoin outtx regardless of the cctx status + +### Refactoring + +* [1391](https://github.com/zeta-chain/node/pull/1391) - consolidate node builds +* update `MsgUpdateContractBytecode` to use code hash instead of contract address + +### Chores + +### Tests +- Add unit tests for adding votes to a ballot +### CI + ## Version: v10.1.2 -### What's Changed: -* bfa1cb8 skip mainnet addresses in cctxs -* 6e1fb4a skip garbage trackers and increase btc gas fee -* fix: added upgrade name, and allow download. allows to test release can. by @gzukel in https://github.com/zeta-chain/node/pull/1195 -* chore: switch back to `cosmos/cosmos-sdk` by @lumtis in https://github.com/zeta-chain/node/pull/1193 -* test: Stateful upgrade by @kevinssgh in https://github.com/zeta-chain/node/pull/1135 -* fix: address `cosmos-gosec` lint issues by @lumtis in https://github.com/zeta-chain/node/pull/1153 -* chore: changed maxNestedMsgs by @CharlieMc0 in https://github.com/zeta-chain/node/pull/1222 -* ci: cross-compile release binaries and simplify PR testings by @CharlieMc0 in https://github.com/zeta-chain/node/pull/1218 -* feat: external stress test by @kevinssgh in https://github.com/zeta-chain/node/pull/1137 -* feat: allow setting liquidity cap for ZRC20 by @lumtis in https://github.com/zeta-chain/node/pull/1205 -* refactor: call `onCrossChainCall` when depositing to a contract by @lumtis in https://github.com/zeta-chain/node/pull/1226 -* fix(`rpc`): adding namespaces back by @lumtis in https://github.com/zeta-chain/node/pull/1228 -* refactor(`cmd`): change default mempool version in config by @lumtis in https://github.com/zeta-chain/node/pull/1238 -* fix(`MsgWhitelistERC20`): set unique index for generate cctx by @lumtis in https://github.com/zeta-chain/node/pull/1245 -* fix(`observer`): remove error return in `IsAuthorized` by @lumtis in https://github.com/zeta-chain/node/pull/1250 -* fix(`GetForeignCoinFromAsset`): Ethereum comparaison checksum/non-checksum format by @lumtis in https://github.com/zeta-chain/node/pull/1261 -* feat(`fungible`): add ability to update gas limit by @lumtis in https://github.com/zeta-chain/node/pull/1260 -* fix: Blame index update by @kevinssgh in https://github.com/zeta-chain/node/pull/1264 -* fix: feed sataoshi/B to zetacore and check actual outTx size by @ws4charlie in https://github.com/zeta-chain/node/pull/1243 -* fix: cherry pick all hotfix from v10.0.x (zero-amount, precision, etc.) by @ws4charlie in https://github.com/zeta-chain/node/pull/1235 -* fix: register emissions grpc server by @kingpinXD in https://github.com/zeta-chain/node/pull/1257 -* feat: Bitcoin block header and merkle proof by @ws4charlie in https://github.com/zeta-chain/node/pull/1263 -* fix: read gas limit from smart contract by @lumtis in https://github.com/zeta-chain/node/pull/1277 -* fix(`fungible`): add CLI command to query system contract by @lumtis in https://github.com/zeta-chain/node/pull/1252 -* fix(`cmd`): add notice when using `--ledger` with Ethereum HD path by @lumtis in https://github.com/zeta-chain/node/pull/1285 -* fix: gosec issues by @lumtis in https://github.com/zeta-chain/node/pull/1290 -* refactor: remove duplicate funtion name IsEthereum by @lukema95 in https://github.com/zeta-chain/node/pull/1279 -* fix: query outtx tracker by chain using prefixed store by @ws4charlie in https://github.com/zeta-chain/node/pull/1283 -* refactor: skip gas stability pool funding when gasLimit is equal gasUsed by @lukema95 in https://github.com/zeta-chain/node/pull/1289 -* fix: minor fixes to stateful upgrade by @kevinssgh in https://github.com/zeta-chain/node/pull/1280 -* ci: add mainnet builds to goreleaser by @CharlieMc0 in https://github.com/zeta-chain/node/pull/1302 -* feat(`fungible`): add query command to get all gas stability pool balances by @lumtis in https://github.com/zeta-chain/node/pull/1247 -* feat: tss funds migration by @kingpinXD in https://github.com/zeta-chain/node/pull/1143 -* fix(`gas-payment`): remove check `gasObtained == outTxGasFee` by @lumtis in https://github.com/zeta-chain/node/pull/1304 -* chore: sync from mockmain by @brewmaster012 in https://github.com/zeta-chain/node/pull/1265 -* chore: increment handler version by @kingpinXD in https://github.com/zeta-chain/node/pull/1307 -* fix: begin blocker for mock mainnet by @kingpinXD in https://github.com/zeta-chain/node/pull/1308 +### Features +* [1137](https://github.com/zeta-chain/node/pull/1137) - external stress testing +* [1205](https://github.com/zeta-chain/node/pull/1205) - allow setting liquidity cap for ZRC20 +* [1260](https://github.com/zeta-chain/node/pull/1260) - add ability to update gas limit +* [1263](https://github.com/zeta-chain/node/pull/1263) - Bitcoin block header and merkle proof +* [1247](https://github.com/zeta-chain/node/pull/1247) - add query command to get all gas stability pool balances +* [1143](https://github.com/zeta-chain/node/pull/1143) - tss funds migration capability +* [1358](https://github.com/zeta-chain/node/pull/1358) - zetaclient thread for zeta supply checks +* [1384](https://github.com/zeta-chain/node/pull/1384) - tx to update an observer +### Fixes + +* [1195](https://github.com/zeta-chain/node/pull/1195) - added upgrade name, and allow download. allows to test release +* [1153](https://github.com/zeta-chain/node/pull/1153) - address `cosmos-gosec` lint issues +* [1128](https://github.com/zeta-chain/node/pull/1228) - adding namespaces back in rpc +* [1245](https://github.com/zeta-chain/node/pull/1245) - set unique index for generate cctx +* [1250](https://github.com/zeta-chain/node/pull/1250) - remove error return in `IsAuthorized` +* [1261](https://github.com/zeta-chain/node/pull/1261) - Ethereum comparaison checksum/non-checksum format +* [1264](https://github.com/zeta-chain/node/pull/1264) - Blame index update +* [1243](https://github.com/zeta-chain/node/pull/1243) - feed sataoshi/B to zetacore and check actual outTx size +* [1235](https://github.com/zeta-chain/node/pull/1235) - cherry pick all hotfix from v10.0.x (zero-amount, precision, etc.) +* [1257](https://github.com/zeta-chain/node/pull/1257) - register emissions grpc server +* [1277](https://github.com/zeta-chain/node/pull/1277) - read gas limit from smart contract +* [1252](https://github.com/zeta-chain/node/pull/1252) - add CLI command to query system contract +* [1285](https://github.com/zeta-chain/node/pull/1285) - add notice when using `--ledger` with Ethereum HD path +* [1283](https://github.com/zeta-chain/node/pull/1283) - query outtx tracker by chain using prefixed store +* [1280](https://github.com/zeta-chain/node/pull/1280) - minor fixes to stateful upgrade +* [1304](https://github.com/zeta-chain/node/pull/1304) - remove check `gasObtained == outTxGasFee` +* [1308](https://github.com/zeta-chain/node/pull/1308) - begin blocker for mock mainnet + +### Refactoring + +* [1226](https://github.com/zeta-chain/node/pull/1226) - call `onCrossChainCall` when depositing to a contract +* [1238](https://github.com/zeta-chain/node/pull/1238) - change default mempool version in config +* [1279](https://github.com/zeta-chain/node/pull/1279) - remove duplicate funtion name IsEthereum +* [1289](https://github.com/zeta-chain/node/pull/1289) - skip gas stability pool funding when gasLimit is equal gasUsed + +### Chores + +* [1193](https://github.com/zeta-chain/node/pull/1193) - switch back to `cosmos/cosmos-sdk` +* [1222](https://github.com/zeta-chain/node/pull/1222) - changed maxNestedMsgs +* [1265](https://github.com/zeta-chain/node/pull/1265) - sync from mockmain +* [1307](https://github.com/zeta-chain/node/pull/1307) - increment handler version + +### Tests + +* [1135](https://github.com/zeta-chain/node/pull/1135) - Stateful upgrade for smoke tests +### CI +* [1218](https://github.com/zeta-chain/node/pull/1218) - cross-compile release binaries and simplify PR testings +* [1302](https://github.com/zeta-chain/node/pull/1302) - add mainnet builds to goreleaser diff --git a/cmd/config_mock_mainnet.go b/cmd/config.go similarity index 82% rename from cmd/config_mock_mainnet.go rename to cmd/config.go index c8f775c61c..978d90c433 100644 --- a/cmd/config_mock_mainnet.go +++ b/cmd/config.go @@ -1,6 +1,3 @@ -//go:build MOCK_MAINNET -// +build MOCK_MAINNET - package cmd const ( @@ -11,6 +8,5 @@ const ( Bech32PrefixConsAddr = "zetac" Bech32PrefixConsPub = "zetacpub" DenomRegex = `[a-zA-Z][a-zA-Z0-9:\\/\\\-\\_\\.]{2,127}` - ZetaChainCoinType uint32 = 60 ZetaChainHDPath string = `m/44'/60'/0'/0/0` ) diff --git a/cmd/config_mainnet.go b/cmd/config_mainnet.go deleted file mode 100644 index dcc8c4f9e2..0000000000 --- a/cmd/config_mainnet.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build !PRIVNET && !TESTNET && !MOCK_MAINNET -// +build !PRIVNET,!TESTNET,!MOCK_MAINNET - -package cmd - -const ( - Bech32PrefixAccAddr = "zeta" - Bech32PrefixAccPub = "zetapub" - Bech32PrefixValAddr = "zetav" - Bech32PrefixValPub = "zetavpub" - Bech32PrefixConsAddr = "zetac" - Bech32PrefixConsPub = "zetacpub" - DenomRegex = `[a-zA-Z][a-zA-Z0-9:\\/\\\-\\_\\.]{2,127}` - ZetaChainCoinType uint32 = 60 - ZetaChainHDPath string = `m/44'/60'/0'/0/0` -) diff --git a/cmd/config_privnet.go b/cmd/config_privnet.go deleted file mode 100644 index 0f95268c18..0000000000 --- a/cmd/config_privnet.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package cmd - -const ( - Bech32PrefixAccAddr = "zeta" - Bech32PrefixAccPub = "zetapub" - Bech32PrefixValAddr = "zetav" - Bech32PrefixValPub = "zetavpub" - Bech32PrefixConsAddr = "zetac" - Bech32PrefixConsPub = "zetacpub" - DenomRegex = `[a-zA-Z][a-zA-Z0-9:\\/\\\-\\_\\.]{2,127}` - ZetaChainCoinType uint32 = 60 - ZetaChainHDPath string = `m/44'/60'/0'/0/0` - NET = "PRIVNET" -) - -var ( - CHAINID = "athens_101-1" -) diff --git a/cmd/config_testnet.go b/cmd/config_testnet.go deleted file mode 100644 index 12f92d7c38..0000000000 --- a/cmd/config_testnet.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build TESTNET -// +build TESTNET - -package cmd - -const ( - Bech32PrefixAccAddr = "zeta" - Bech32PrefixAccPub = "zetapub" - Bech32PrefixValAddr = "zetav" - Bech32PrefixValPub = "zetavpub" - Bech32PrefixConsAddr = "zetac" - Bech32PrefixConsPub = "zetacpub" - DenomRegex = `[a-zA-Z][a-zA-Z0-9:\\/\\\-\\_\\.]{2,127}` - ZetaChainCoinType uint32 = 60 - ZetaChainHDPath string = `m/44'/60'/0'/0/0` - NET = "TESTNET" -) - -var ( - CHAINID = "athens_7001-1" -) diff --git a/cmd/zetaclientd/aux.go b/cmd/zetaclientd/aux.go index af79383a3e..8f447340ae 100644 --- a/cmd/zetaclientd/aux.go +++ b/cmd/zetaclientd/aux.go @@ -16,6 +16,11 @@ func CreateAuthzSigner(granter string, grantee sdk.AccAddress) { } func CreateZetaBridge(cfg *config.Config) (*zetaclient.ZetaCoreBridge, error) { + hotKey := cfg.AuthzHotkey + if cfg.HsmMode { + hotKey = cfg.HsmHotKey + } + chainIP := cfg.ZetaCoreURL kb, _, err := zetaclient.GetKeyringKeybase(cfg) @@ -30,7 +35,7 @@ func CreateZetaBridge(cfg *config.Config) (*zetaclient.ZetaCoreBridge, error) { k := zetaclient.NewKeysWithKeybase(kb, granterAddreess, cfg.AuthzHotkey) - bridge, err := zetaclient.NewZetaCoreBridge(k, chainIP, cfg.AuthzHotkey, cfg.ChainID) + bridge, err := zetaclient.NewZetaCoreBridge(k, chainIP, hotKey, cfg.ChainID, cfg.HsmMode) if err != nil { return nil, err } diff --git a/cmd/zetaclientd/debug.go b/cmd/zetaclientd/debug.go index 48cae761b2..c9ebb3dba4 100644 --- a/cmd/zetaclientd/debug.go +++ b/cmd/zetaclientd/debug.go @@ -53,7 +53,7 @@ func DebugCmd() *cobra.Command { txHash := args[0] var ballotIdentifier string chainLogger := zerolog.New(io.Discard).Level(zerolog.Disabled) - bridge, err := zetaclient.NewZetaCoreBridge(&zetaclient.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())}, debugArgs.zetaNode, "", debugArgs.zetaChainID) + bridge, err := zetaclient.NewZetaCoreBridge(&zetaclient.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())}, debugArgs.zetaNode, "", debugArgs.zetaChainID, false) if err != nil { return err } diff --git a/cmd/zetaclientd/hsm.go b/cmd/zetaclientd/hsm.go new file mode 100644 index 0000000000..d15ac3b1bd --- /dev/null +++ b/cmd/zetaclientd/hsm.go @@ -0,0 +1,102 @@ +package main + +import ( + "fmt" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + keystone "github.com/zeta-chain/keystone/keys" + "github.com/zeta-chain/zetacore/cmd" + "github.com/zeta-chain/zetacore/common/cosmos" + "github.com/zeta-chain/zetacore/zetaclient/hsm" +) + +var HsmCmd = &cobra.Command{ + Use: "hsm", + Short: "Utility command to interact with hsm", +} + +var GetHsmAddressCmd = &cobra.Command{ + Use: "get-address", + Short: "Get the address of a particular keypair by label", + RunE: GetHsmAddress, +} + +var GenerateHsmKeyCmd = &cobra.Command{ + Use: "gen-key", + Short: "Generate keypair by label", + RunE: GenerateHsmKey, +} + +type HsmArgs struct { + label string +} + +type HsmGenKeyArgs struct { + algorithm int +} + +var hsmArgs = HsmArgs{} +var hsmKeyGenArgs = HsmGenKeyArgs{} + +func init() { + RootCmd.AddCommand(HsmCmd) + HsmCmd.AddCommand(GetHsmAddressCmd) + HsmCmd.AddCommand(GenerateHsmKeyCmd) + + // HSM root arguments + HsmCmd.PersistentFlags().StringVar(&hsmArgs.label, "key-label", "", "label used to identify key on HSM") + + // HSM key gen arguments + GenerateHsmKeyCmd.Flags().IntVar(&hsmKeyGenArgs.algorithm, "algorithm", 0, "key algo; 0=SECP256K1, 1=SECP256R1, 2=ED25519") +} + +func GetHsmAddress(_ *cobra.Command, _ []string) error { + SetupConfigForTest() + + config, err := hsm.GetPKCS11Config() + if err != nil { + return err + } + _, pubKey, err := hsm.GetHSMAddress(config, hsmArgs.label) + if err != nil { + return err + } + + address, err := cosmos.Bech32ifyAddressBytes(cmd.Bech32PrefixAccAddr, pubKey.Address().Bytes()) + if err != nil { + return err + } + zetaPubKey, err := cosmos.Bech32ifyPubKey(cosmos.Bech32PubKeyTypeAccPub, pubKey) + if err != nil { + return err + } + + // Print formatted result + fmt.Println("Address: ", address) + fmt.Println("Public Key: ", zetaPubKey) + fmt.Println("Label: ", hsmArgs.label) + + return nil +} + +func GenerateHsmKey(_ *cobra.Command, _ []string) error { + config, err := hsm.GetPKCS11Config() + if err != nil { + return err + } + if hsmKeyGenArgs.algorithm > 2 || hsmKeyGenArgs.algorithm < 0 { + return errors.New("invalid algorithm selected") + } + algo := []keystone.KeygenAlgorithm{keystone.KEYGEN_SECP256K1, keystone.KEYGEN_SECP256R1, keystone.KEYGEN_ED25519} + key, err := hsm.GenerateKey(hsmArgs.label, algo[hsmKeyGenArgs.algorithm], config) + if err != nil { + return err + } + + // Print Generated key + fmt.Println("Public Key: ", key.PubKey().String()) + fmt.Println("Label: ", hsmArgs.label) + + return nil +} diff --git a/cmd/zetaclientd/init.go b/cmd/zetaclientd/init.go index 95f3d9ca86..3ae36cf66b 100644 --- a/cmd/zetaclientd/init.go +++ b/cmd/zetaclientd/init.go @@ -32,6 +32,8 @@ type initArguments struct { TssPath string TestTssKeysign bool KeyringBackend string + HsmMode bool + HsmHotKey string } func init() { @@ -54,6 +56,8 @@ func init() { InitCmd.Flags().StringVar(&initArgs.TssPath, "tss-path", "~/.tss", "path to tss location") InitCmd.Flags().BoolVar(&initArgs.TestTssKeysign, "test-tss", false, "set to to true to run a check for TSS keysign on startup") InitCmd.Flags().StringVar(&initArgs.KeyringBackend, "keyring-backend", string(config.KeyringBackendTest), "keyring backend to use (test, file)") + InitCmd.Flags().BoolVar(&initArgs.HsmMode, "hsm-mode", false, "enable hsm signer, default disabled") + InitCmd.Flags().StringVar(&initArgs.HsmHotKey, "hsm-hotkey", "hsm-hotkey", "name of hotkey associated with hardware security module") } func Initialize(_ *cobra.Command, _ []string) error { @@ -89,6 +93,8 @@ func Initialize(_ *cobra.Command, _ []string) error { configData.P2PDiagnosticTicker = initArgs.p2pDiagnosticTicker configData.ConfigUpdateTicker = initArgs.configUpdateTicker configData.KeyringBackend = config.KeyringBackend(initArgs.KeyringBackend) + configData.HsmMode = initArgs.HsmMode + configData.HsmHotKey = initArgs.HsmHotKey //Save config file return config.Save(&configData, rootArgs.zetaCoreHome) diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index f30070cb62..bc80814831 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -21,9 +21,36 @@ import ( "github.com/zeta-chain/zetacore/zetaclient/metrics" ) -func GenerateTss(logger zerolog.Logger, cfg *config.Config, zetaBridge *mc.ZetaCoreBridge, peers p2p.AddrList, priKey secp256k1.PrivKey, ts *mc.TelemetryServer, tssHistoricalList []types.TSS, metrics *metrics.Metrics) (*mc.TSS, error) { +func GenerateTss( + logger zerolog.Logger, + cfg *config.Config, + zetaBridge *mc.ZetaCoreBridge, + peers p2p.AddrList, + priKey secp256k1.PrivKey, + ts *mc.TelemetryServer, + tssHistoricalList []types.TSS, + metrics *metrics.Metrics, +) (*mc.TSS, error) { keygenLogger := logger.With().Str("module", "keygen").Logger() - tss, err := mc.NewTSS(peers, priKey, preParams, cfg, zetaBridge, tssHistoricalList, metrics) + + // Bitcoin chain ID is currently used for using the correct signature format + // TODO: remove this once we have a better way to determine the signature format + // https://github.com/zeta-chain/node/issues/1397 + bitcoinChainID := common.BtcRegtestChain().ChainId + if cfg.BitcoinConfig != nil { + bitcoinChainID = cfg.BitcoinConfig.ChainId + } + + tss, err := mc.NewTSS( + peers, + priKey, + preParams, + cfg, + zetaBridge, + tssHistoricalList, + metrics, + bitcoinChainID, + ) if err != nil { keygenLogger.Error().Err(err).Msg("NewTSS error") return nil, err @@ -135,7 +162,7 @@ func keygenTss(cfg *config.Config, tss *mc.TSS, keygenLogger zerolog.Logger) err return err } index := fmt.Sprintf("keygen-%s-%d", digest, keyGen.BlockNumber) - zetaHash, err := tss.CoreBridge.PostBlameData(&res.Blame, common.ZetaChain().ChainId, index) + zetaHash, err := tss.CoreBridge.PostBlameData(&res.Blame, tss.CoreBridge.ZetaChain().ChainId, index) if err != nil { keygenLogger.Error().Err(err).Msg("error sending blame data to core") return err diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 230bda49c3..8a9eca8136 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -86,7 +86,10 @@ func start(_ *cobra.Command, _ []string) error { if strings.Compare(res.GetDefaultNodeInfo().Network, cfg.ChainID) != 0 { startLogger.Warn().Msgf("chain id mismatch, zeta-core chain id %s, zeta client chain id %s; reset zeta client chain id", res.GetDefaultNodeInfo().Network, cfg.ChainID) cfg.ChainID = res.GetDefaultNodeInfo().Network - zetaBridge.UpdateChainID(cfg.ChainID) + err := zetaBridge.UpdateChainID(cfg.ChainID) + if err != nil { + return err + } } // CreateAuthzSigner : which is used to sign all authz messages . All votes broadcast to zetacore are wrapped in authz exec . @@ -106,6 +109,7 @@ func start(_ *cobra.Command, _ []string) error { go zetaBridge.ConfigUpdater(cfg) // Generate TSS address . The Tss address is generated through Keygen ceremony. The TSS key is used to sign all outbound transactions . + // The bridgePk is private key for the Hotkey. The Hotkey is used to sign all inbound transactions // Each node processes a portion of the key stored in ~/.tss by default . Custom location can be specified in config file during init. // After generating the key , the address is set on the zetacore bridgePk, err := zetaBridge.GetKeys().GetPrivateKey() @@ -203,15 +207,11 @@ func start(_ *cobra.Command, _ []string) error { isNodeActive := false for _, observer := range observerList { if observer == zetaBridge.GetKeys().GetOperatorAddress().String() { - startLogger.Info().Msgf("Observer %s is active", zetaBridge.GetKeys().GetOperatorAddress().String()) isNodeActive = true break } } - if !isNodeActive { - startLogger.Error().Msgf("Node %s is not an active observer", zetaBridge.GetKeys().GetOperatorAddress().String()) - return errors.New("Node is not an active observer") - } + // CreateSignerMap: This creates a map of all signers for each chain . Each signer is responsible for signing transactions for a particular chain signerMap, err := CreateSignerMap(tss, masterLogger, cfg, telemetryServer) if err != nil { @@ -232,14 +232,34 @@ func start(_ *cobra.Command, _ []string) error { startLogger.Err(err).Msg("CreateSignerMap") return err } - for _, v := range chainClientMap { - v.Start() + + if !isNodeActive { + startLogger.Error().Msgf("Node %s is not an active observer external chain observers will not be started", zetaBridge.GetKeys().GetOperatorAddress().String()) + } else { + startLogger.Debug().Msgf("Node %s is an active observer starting external chain observers", zetaBridge.GetKeys().GetOperatorAddress().String()) + for _, v := range chainClientMap { + v.Start() + } } // CreateCoreObserver : Core observer wraps the zetacore bridge and adds the client and signer maps to it . This is the high level object used for CCTX interactions mo1 := mc.NewCoreObserver(zetaBridge, signerMap, chainClientMap, metrics, masterLogger, cfg, telemetryServer) mo1.MonitorCore() + // start zeta supply checker + // TODO: enable + // https://github.com/zeta-chain/node/issues/1354 + // NOTE: this is disabled for now because we need to determine the frequency on how to handle invalid check + // The method uses GRPC query to the node we might need to improve for performance + //zetaSupplyChecker, err := mc.NewZetaSupplyChecker(cfg, zetaBridge, masterLogger) + //if err != nil { + // startLogger.Err(err).Msg("NewZetaSupplyChecker") + //} + //if err == nil { + // zetaSupplyChecker.Start() + // defer zetaSupplyChecker.Stop() + //} + startLogger.Info().Msgf("awaiting the os.Interrupt, syscall.SIGTERM signals...") ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) diff --git a/cmd/zetacored/config/prefix_testnet.go b/cmd/zetacored/config/prefix_testnet.go deleted file mode 100644 index 8f3f628c88..0000000000 --- a/cmd/zetacored/config/prefix_testnet.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:build testnet -// +build testnet - -package config - -import sdk "github.com/cosmos/cosmos-sdk/types" - -const ( - // Bech32Prefix defines the Bech32 prefix used for Cronos Accounts - Bech32Prefix = "tzeta" - - // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address - Bech32PrefixAccAddr = Bech32Prefix - // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key - Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic - // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address - Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator - // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key - Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic - // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address - Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus - // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key - Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic -) diff --git a/cmd/zetacored/config/prefix_mainnet.go b/cmd/zetacored/config/prefixes.go similarity index 96% rename from cmd/zetacored/config/prefix_mainnet.go rename to cmd/zetacored/config/prefixes.go index 5c148c9dd7..a96a4c57bc 100644 --- a/cmd/zetacored/config/prefix_mainnet.go +++ b/cmd/zetacored/config/prefixes.go @@ -1,6 +1,3 @@ -//go:build !testnet -// +build !testnet - package config import sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/cmd/zetacored/observer_accounts.go b/cmd/zetacored/observer_accounts.go index 397146a688..f4bd0d290f 100644 --- a/cmd/zetacored/observer_accounts.go +++ b/cmd/zetacored/observer_accounts.go @@ -77,6 +77,7 @@ func AddObserverAccountsCmd() *cobra.Command { var nodeAccounts []*types.NodeAccount var keygenPubKeys []string observersForChain := map[int64][]string{} + // DefaultChainsList is based on Build Flags supportedChains := common.DefaultChainsList() var balances []banktypes.Balance diff --git a/cmd/zetacored/parsers_test.go b/cmd/zetacored/parsers_test.go index cb7cb62190..f3310717ef 100644 --- a/cmd/zetacored/parsers_test.go +++ b/cmd/zetacored/parsers_test.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( diff --git a/common/address.go b/common/address.go index 592daa0775..032a0b88b0 100644 --- a/common/address.go +++ b/common/address.go @@ -1,7 +1,6 @@ package common import ( - "fmt" "strings" eth "github.com/ethereum/go-ethereum/common" @@ -19,16 +18,12 @@ var ( const ETHAddressLen = 42 // NewAddress create a new Address. Supports Ethereum, BSC, Polygon -func NewAddress(address string, chain Chain) (Address, error) { - +func NewAddress(address string) Address { // Check is eth address - if IsEVMChain(chain.ChainId) { - if eth.IsHexAddress(address) { - return Address(address), nil - } + if eth.IsHexAddress(address) { + return Address(address) } - - return NoAddress, fmt.Errorf("address format not supported: %s", address) + return NoAddress } func (addr Address) AccAddress() (cosmos.AccAddress, error) { diff --git a/common/address_test.go b/common/address_test.go index 17bfe5ce86..4487c48e28 100644 --- a/common/address_test.go +++ b/common/address_test.go @@ -1,44 +1,22 @@ -//go:build TESTNET -// +build TESTNET - package common import ( "testing" + "github.com/stretchr/testify/require" + . "gopkg.in/check.v1" ) func TestPackage(t *testing.T) { TestingT(t) } -type AddressSuite struct{} - -var _ = Suite(&AddressSuite{}) - -func (s *AddressSuite) TestAddress(c *C) { - _, err := NewAddress("bnb1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6", GoerliChain()) - c.Assert(err, NotNil) - - _, err = NewAddress("1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6", GoerliChain()) - c.Check(err, NotNil) - _, err = NewAddress("bnb1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6X", GoerliChain()) - c.Check(err, NotNil) - _, err = NewAddress("bogus", GoerliChain()) - c.Check(err, NotNil) - c.Check(Address("").IsEmpty(), Equals, true) - c.Check(NoAddress.Equals(Address("")), Equals, true) - _, err = NewAddress("", GoerliChain()) - c.Assert(err, NotNil) - - // eth tests - _, err = NewAddress("0x90f2b1ae50e6018230e90a33f98c7844a0ab635a", GoerliChain()) - c.Check(err, IsNil) - // wrong length - _, err = NewAddress("0x90f2b1ae50e6018230e90a33f98c7844a0ab635aaaaaaaaa", GoerliChain()) - c.Check(err, NotNil) +func TestAddress(t *testing.T) { + addr := NewAddress("bnb1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6") + require.EqualValuesf(t, NoAddress, addr, "address string should be empty") - // good length but not valid hex string - _, err = NewAddress("0x90f2b1ae50e6018230e90a33f98c7844a0ab63zz", GoerliChain()) - c.Check(err, NotNil) + addr = NewAddress("bogus") + require.EqualValuesf(t, NoAddress, addr, "address string should be empty") + addr = NewAddress("0x90f2b1ae50e6018230e90a33f98c7844a0ab635a") + require.EqualValuesf(t, "0x90f2b1ae50e6018230e90a33f98c7844a0ab635a", addr.String(), "address string should be equal") } diff --git a/common/bitcoin.go b/common/bitcoin.go new file mode 100644 index 0000000000..37a52f7986 --- /dev/null +++ b/common/bitcoin.go @@ -0,0 +1,27 @@ +package common + +import ( + "fmt" + + "github.com/btcsuite/btcd/chaincfg" +) + +var ( + BitcoinMainnetParams = &chaincfg.MainNetParams + BitcoinRegnetParams = &chaincfg.RegressionNetParams + BitcoinTestnetParams = &chaincfg.TestNet3Params +) + +// BitcoinNetParamsFromChainID returns the bitcoin net params to be used from the chain id +func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { + switch chainID { + case BtcRegtestChain().ChainId: + return BitcoinRegnetParams, nil + case BtcMainnetChain().ChainId: + return BitcoinMainnetParams, nil + case BtcTestNetChain().ChainId: + return BitcoinTestnetParams, nil + default: + return nil, fmt.Errorf("no Bitcoin net params for chain ID: %d", chainID) + } +} diff --git a/common/chain.go b/common/chain.go index 2ef7116ede..70f3252e36 100644 --- a/common/chain.go +++ b/common/chain.go @@ -9,12 +9,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" ) -var ( - SigningAlgoSecp256k1 = SigninAlgo("secp256k1") - SigningAlgoEd25519 = SigninAlgo("ed25519") -) - -// return the ChainName from a string +// ParseChainName returns the ChainName from a string // if no such name exists, returns the empty chain name: ChainName_empty func ParseChainName(chain string) ChainName { c := ChainName_value[chain] @@ -23,28 +18,25 @@ func ParseChainName(chain string) ChainName { type SigninAlgo string -// Chain is an alias of string , represent a block chain -//type Chain string - // Chains represent a slice of Chain type Chains []Chain -// Equals compare two chain to see whether they represent the same chain +// IsEqual compare two chain to see whether they represent the same chain func (chain Chain) IsEqual(c Chain) bool { - if chain.ChainName == c.ChainName && chain.ChainId == c.ChainId { + if chain.ChainId == c.ChainId { return true } return false } func (chain Chain) IsZetaChain() bool { - return chain.IsEqual(ZetaChain()) + return chain.InChainList(ZetaChainList()) } func (chain Chain) IsExternalChain() bool { - return !chain.IsEqual(ZetaChain()) + return !chain.InChainList(ZetaChainList()) } -// bytes representations of address +// EncodeAddress bytes representations of address // on EVM chain, it is 20Bytes // on Bitcoin chain, it is P2WPKH address, []byte(bech32 encoded string) func (chain Chain) EncodeAddress(b []byte) (string, error) { @@ -94,6 +86,10 @@ func (chain Chain) DecodeAddress(addr string) ([]byte, error) { return nil, fmt.Errorf("chain (%d) not supported", chain.ChainId) } +func IsZetaChain(chainID int64) bool { + return ChainIDInChainList(chainID, ZetaChainList()) +} + func IsEVMChain(chainID int64) bool { return chainID == 5 || // Goerli chainID == 80001 || // Polygon mumbai @@ -168,16 +164,6 @@ func (chains Chains) Strings() []string { return strings } -func GetChainFromChainName(chainName ChainName) *Chain { - chains := DefaultChainsList() - for _, chain := range chains { - if chainName == chain.ChainName { - return chain - } - } - return nil -} - func GetChainFromChainID(chainID int64) *Chain { chains := DefaultChainsList() for _, chain := range chains { @@ -208,3 +194,18 @@ func GetBTCChainParams(chainID int64) (*chaincfg.Params, error) { return nil, fmt.Errorf("error chainID %d is not a Bitcoin chain", chainID) } } + +// InChainList checks whether the chain is in the chain list +func (chain Chain) InChainList(chainList []*Chain) bool { + return ChainIDInChainList(chain.ChainId, chainList) +} + +// ChainIDInChainList checks whether the chainID is in the chain list +func ChainIDInChainList(chainID int64, chainList []*Chain) bool { + for _, c := range chainList { + if chainID == c.ChainId { + return true + } + } + return false +} diff --git a/common/chain_id.go b/common/chain_id.go new file mode 100644 index 0000000000..1be8a0129a --- /dev/null +++ b/common/chain_id.go @@ -0,0 +1,41 @@ +package common + +import ( + "errors" + "fmt" + "strconv" + "strings" +) + +// CosmosToEthChainID converts a Cosmos chain ID to an Ethereum chain ID +// parse value between _ and - +// e.g. cosmoshub_400-1 -> 400 +func CosmosToEthChainID(chainID string) (int64, error) { + // extract the substring + extracted, err := extractBetweenUnderscoreAndDash(chainID) + if err != nil { + return 0, fmt.Errorf("can't convert cosmos to ethereum chain id: %w", err) + } + + // convert to int64 + ethChainID, err := strconv.ParseInt(extracted, 10, 64) + if err != nil { + return 0, fmt.Errorf("can't convert cosmos to ethereum chain id: %w", err) + } + + return ethChainID, nil +} + +func extractBetweenUnderscoreAndDash(s string) (string, error) { + // Find the position of the underscore and dash + underscoreIndex := strings.Index(s, "_") + dashIndex := strings.Index(s, "-") + + // Check if both characters are found and in the correct order + if underscoreIndex == -1 || dashIndex == -1 || underscoreIndex > dashIndex { + return "", errors.New("value does not contain underscore followed by dash") + } + + // Extract and return the substring + return s[underscoreIndex+1 : dashIndex], nil +} diff --git a/common/chain_id_test.go b/common/chain_id_test.go new file mode 100644 index 0000000000..cd4a18ca18 --- /dev/null +++ b/common/chain_id_test.go @@ -0,0 +1,58 @@ +package common_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/common" +) + +func TestCosmosToEthChainID(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + chainID string + expected int64 + isErr bool + }{ + { + name: "valid chain ID", + chainID: "cosmoshub_400-1", + expected: 400, + }, + { + name: "another valid chain ID", + chainID: "athens_701-2", + expected: 701, + }, + { + name: "no underscore", + chainID: "athens701-2", + isErr: true, + }, + { + name: "no dash", + chainID: "athens_7012", + isErr: true, + }, + { + name: "wrong pattern", + chainID: "athens-701_2", + isErr: true, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ethChainID, err := common.CosmosToEthChainID(tc.chainID) + if tc.isErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tc.expected, ethChainID) + } + }) + } +} diff --git a/common/chain_network.go b/common/chain_network.go deleted file mode 100644 index cb4f386fad..0000000000 --- a/common/chain_network.go +++ /dev/null @@ -1,40 +0,0 @@ -package common - -import ( - "os" - "strings" -) - -// ChainNetwork is to indicate which chain environment THORNode are working with -type ChainNetwork uint8 - -const ( - // TestNet network for test - TestNet ChainNetwork = iota - // MainNet network for main net - MainNet - // MockNet network for main net - MockNet -) - -// GetCurrentChainNetwork determinate what kind of network currently it is working with -func GetCurrentChainNetwork() ChainNetwork { - if strings.EqualFold(os.Getenv("NET"), "mocknet") { - return MockNet - } - if strings.EqualFold(os.Getenv("NET"), "testnet") { - return TestNet - } - return MainNet -} - -// Soft Equals check is mainnet == mainet, or (testnet/mocknet == testnet/mocknet) -func (net ChainNetwork) SoftEquals(net2 ChainNetwork) bool { - if net == MainNet && net2 == MainNet { - return true - } - if net != MainNet && net2 != MainNet { - return true - } - return false -} diff --git a/common/chain_network_test.go b/common/chain_network_test.go deleted file mode 100644 index 9aa804e76e..0000000000 --- a/common/chain_network_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package common - -import ( - . "gopkg.in/check.v1" -) - -type ChainNetworkSuite struct{} - -var _ = Suite(&ChainNetworkSuite{}) - -func (s *ChainNetworkSuite) TestSoftEquals(c *C) { - c.Assert(MainNet.SoftEquals(MainNet), Equals, true) - c.Assert(TestNet.SoftEquals(TestNet), Equals, true) - c.Assert(MockNet.SoftEquals(MockNet), Equals, true) - c.Assert(TestNet.SoftEquals(MockNet), Equals, true) - c.Assert(MainNet.SoftEquals(MockNet), Equals, false) - c.Assert(MainNet.SoftEquals(TestNet), Equals, false) -} diff --git a/common/chain_test.go b/common/chain_test.go index 28ab1be701..f0e3c1ceed 100644 --- a/common/chain_test.go +++ b/common/chain_test.go @@ -7,11 +7,6 @@ import ( ) func TestChain_EncodeAddress(t *testing.T) { - type fields struct { - ChainName ChainName - ChainId int32 - } - tests := []struct { name string chain Chain @@ -53,3 +48,11 @@ func TestChain_EncodeAddress(t *testing.T) { }) } } + +func TestChain_InChainList(t *testing.T) { + require.True(t, ZetaChainMainnet().InChainList(ZetaChainList())) + require.True(t, ZetaMocknetChain().InChainList(ZetaChainList())) + require.True(t, ZetaPrivnetChain().InChainList(ZetaChainList())) + require.True(t, ZetaTestnetChain().InChainList(ZetaChainList())) + require.False(t, EthChain().InChainList(ZetaChainList())) +} diff --git a/common/chains.go b/common/chains.go new file mode 100644 index 0000000000..48e6a3213b --- /dev/null +++ b/common/chains.go @@ -0,0 +1,217 @@ +package common + +import "fmt" + +// Zeta chains + +func ZetaChainMainnet() Chain { + return Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 7000, + } +} + +func ZetaTestnetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_testnet, + ChainId: 7001, + } +} + +func ZetaMocknetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 70000, + } +} + +func ZetaPrivnetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 101, + } +} + +// Mainnet chains + +func EthChain() Chain { + return Chain{ + ChainName: ChainName_eth_mainnet, + ChainId: 1, + } +} + +func BscMainnetChain() Chain { + return Chain{ + ChainName: ChainName_bsc_mainnet, + ChainId: 56, + } +} + +func BtcMainnetChain() Chain { + return Chain{ + ChainName: ChainName_btc_mainnet, + ChainId: 8332, + } +} + +func PolygonChain() Chain { + return Chain{ + ChainName: ChainName_polygon_mainnet, + ChainId: 137, + } +} + +// Testnet chains + +func GoerliChain() Chain { + return Chain{ + ChainName: ChainName_goerli_testnet, + ChainId: 5, + } +} + +func BscTestnetChain() Chain { + return Chain{ + ChainName: ChainName_bsc_testnet, + ChainId: 97, + } +} + +func BtcTestNetChain() Chain { + return Chain{ + ChainName: ChainName_btc_testnet, + ChainId: 18332, + } +} + +func MumbaiChain() Chain { + return Chain{ + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + } +} + +// Privnet chains + +func BtcRegtestChain() Chain { + return Chain{ + ChainName: ChainName_btc_regtest, + ChainId: 18444, + } +} + +func GoerliLocalnetChain() Chain { + return Chain{ + ChainName: ChainName_goerli_localnet, + ChainId: 1337, + } +} + +func BtcDustOffset() int64 { + return 2000 +} + +// DefaultChainsList returns a list of default chains +func DefaultChainsList() []*Chain { + return chainListPointers([]Chain{ + BtcMainnetChain(), + BscMainnetChain(), + EthChain(), + BtcTestNetChain(), + MumbaiChain(), + BscTestnetChain(), + GoerliChain(), + BtcRegtestChain(), + GoerliLocalnetChain(), + ZetaChainMainnet(), + ZetaTestnetChain(), + ZetaMocknetChain(), + ZetaPrivnetChain(), + }) +} + +// MainnetChainList returns a list of mainnet chains +func MainnetChainList() []*Chain { + return chainListPointers([]Chain{ + ZetaChainMainnet(), + BtcMainnetChain(), + BscMainnetChain(), + EthChain(), + }) +} + +// TestnetChainList returns a list of testnet chains +func TestnetChainList() []*Chain { + return chainListPointers([]Chain{ + ZetaTestnetChain(), + BtcTestNetChain(), + MumbaiChain(), + BscTestnetChain(), + GoerliChain(), + }) +} + +// PrivnetChainList returns a list of privnet chains +func PrivnetChainList() []*Chain { + return chainListPointers([]Chain{ + ZetaPrivnetChain(), + BtcRegtestChain(), + GoerliLocalnetChain(), + }) +} + +// ExternalChainList returns a list chains that are not Zeta +func ExternalChainList() []*Chain { + return chainListPointers([]Chain{ + BtcMainnetChain(), + BscMainnetChain(), + EthChain(), + BtcTestNetChain(), + MumbaiChain(), + BscTestnetChain(), + GoerliChain(), + BtcRegtestChain(), + GoerliLocalnetChain(), + }) +} + +// ZetaChainList returns a list of Zeta chains +func ZetaChainList() []*Chain { + return chainListPointers([]Chain{ + ZetaChainMainnet(), + ZetaTestnetChain(), + ZetaMocknetChain(), + ZetaPrivnetChain(), + }) +} + +// ZetaChainFromChainID returns a ZetaChain chainobject from a Cosmos chain ID +func ZetaChainFromChainID(chainID string) (Chain, error) { + ethChainID, err := CosmosToEthChainID(chainID) + if err != nil { + return Chain{}, err + } + + switch ethChainID { + case ZetaPrivnetChain().ChainId: + return ZetaPrivnetChain(), nil + case ZetaChainMainnet().ChainId: + return ZetaChainMainnet(), nil + case ZetaTestnetChain().ChainId: + return ZetaTestnetChain(), nil + case ZetaMocknetChain().ChainId: + return ZetaMocknetChain(), nil + default: + return Chain{}, fmt.Errorf("chain %d not found", ethChainID) + } +} + +// chainListPointers returns a list of chain pointers +func chainListPointers(chains []Chain) []*Chain { + var c []*Chain + for i := 0; i < len(chains); i++ { + c = append(c, &chains[i]) + } + return c +} diff --git a/common/cosmos/cosmos.go b/common/cosmos/cosmos.go index d28a882d88..9d0c072a8c 100644 --- a/common/cosmos/cosmos.go +++ b/common/cosmos/cosmos.go @@ -38,6 +38,7 @@ var ( NewKVStoreKey = sdk.NewKVStoreKey NewTransientStoreKey = sdk.NewTransientStoreKey NewContext = sdk.NewContext + Bech32ifyAddressBytes = sdk.Bech32ifyAddressBytes GetPubKeyFromBech32 = legacybech32.UnmarshalPubKey Bech32ifyPubKey = legacybech32.MarshalPubKey Bech32PubKeyTypeConsPub = legacybech32.ConsPK diff --git a/common/default_chains_mainnet.go b/common/default_chains_mainnet.go deleted file mode 100644 index 62b455e571..0000000000 --- a/common/default_chains_mainnet.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build !PRIVNET && !TESTNET && !MOCK_MAINNET -// +build !PRIVNET,!TESTNET,!MOCK_MAINNET - -package common - -func EthChain() Chain { - return Chain{ - ChainName: ChainName_eth_mainnet, - ChainId: 1, - } -} - -func BscMainnetChain() Chain { - return Chain{ - ChainName: ChainName_bsc_mainnet, - ChainId: 56, - } -} - -func ZetaChain() Chain { - return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 7000, - } -} - -func BtcMainnetChain() Chain { - return Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, - } -} - -func BtcChainID() int64 { - return BtcMainnetChain().ChainId -} - -func BtcDustOffset() int64 { - return 2000 -} - -func PolygonChain() Chain { - return Chain{ - ChainName: ChainName_polygon_mainnet, - ChainId: 137, - } -} - -func DefaultChainsList() []*Chain { - chains := []Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - ZetaChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} - -func ExternalChainList() []*Chain { - chains := []Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} diff --git a/common/default_chains_mock_mainnet.go b/common/default_chains_mock_mainnet.go deleted file mode 100644 index 7400f48779..0000000000 --- a/common/default_chains_mock_mainnet.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build MOCK_MAINNET -// +build MOCK_MAINNET - -package common - -func EthChain() Chain { - return Chain{ - ChainName: ChainName_eth_mainnet, - ChainId: 1, - } -} - -func BscMainnetChain() Chain { - return Chain{ - ChainName: ChainName_bsc_mainnet, - ChainId: 56, - } -} - -func ZetaChain() Chain { - return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 70000, - } -} - -func BtcMainnetChain() Chain { - return Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, - } -} - -func BtcChainID() int64 { - return BtcMainnetChain().ChainId -} - -func BtcDustOffset() int64 { - return 2000 -} - -func PolygonChain() Chain { - return Chain{ - ChainName: ChainName_polygon_mainnet, - ChainId: 137, - } -} - -func DefaultChainsList() []*Chain { - chains := []Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - ZetaChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} - -func ExternalChainList() []*Chain { - chains := []Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} diff --git a/common/default_chains_privnet.go b/common/default_chains_privnet.go deleted file mode 100644 index c3cefa0ed4..0000000000 --- a/common/default_chains_privnet.go +++ /dev/null @@ -1,58 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package common - -func GoerliChain() Chain { - return Chain{ - ChainName: ChainName_goerli_localnet, - ChainId: 1337, - } -} - -func ZetaChain() Chain { - return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 101, - } -} - -func BtcRegtestChain() Chain { - return Chain{ - ChainName: ChainName_btc_regtest, - ChainId: 18444, - } -} - -func BtcChainID() int64 { - return BtcRegtestChain().ChainId -} - -func BtcDustOffset() int64 { - return 2000 -} - -func DefaultChainsList() []*Chain { - chains := []Chain{ - BtcRegtestChain(), - GoerliChain(), - ZetaChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} - -func ExternalChainList() []*Chain { - chains := []Chain{ - BtcRegtestChain(), - GoerliChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} diff --git a/common/default_chains_testnet.go b/common/default_chains_testnet.go deleted file mode 100644 index 86ed783c0d..0000000000 --- a/common/default_chains_testnet.go +++ /dev/null @@ -1,76 +0,0 @@ -//go:build TESTNET -// +build TESTNET - -package common - -func GoerliChain() Chain { - return Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - } -} - -func BscTestnetChain() Chain { - return Chain{ - ChainName: ChainName_bsc_testnet, - ChainId: 97, - } -} - -func ZetaChain() Chain { - return Chain{ - ChainName: ChainName_zeta_testnet, - ChainId: 7001, - } -} - -func BtcTestNetChain() Chain { - return Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, - } -} - -func BtcChainID() int64 { - return BtcTestNetChain().ChainId -} - -func BtcDustOffset() int64 { - return 2000 -} - -func MumbaiChain() Chain { - return Chain{ - ChainName: ChainName_mumbai_testnet, - ChainId: 80001, - } -} - -func DefaultChainsList() []*Chain { - chains := []Chain{ - BtcTestNetChain(), - MumbaiChain(), - BscTestnetChain(), - GoerliChain(), - ZetaChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} - -func ExternalChainList() []*Chain { - chains := []Chain{ - BtcTestNetChain(), - MumbaiChain(), - BscTestnetChain(), - GoerliChain(), - } - var c []*Chain - for i := 0; i < len(chains); i++ { - c = append(c, &chains[i]) - } - return c -} diff --git a/common/proof_test.go b/common/proof_test.go index 9f3f958504..0bf1244e80 100644 --- a/common/proof_test.go +++ b/common/proof_test.go @@ -105,7 +105,7 @@ func BitcoinMerkleProofLiveTest(t *testing.T) { } } -func validateBitcoinBlock(t *testing.T, header *wire.BlockHeader, headerBytes []byte, blockVerbose *btcjson.GetBlockVerboseTxResult, outTxid string, tssAddress string, nonce uint64) { +func validateBitcoinBlock(t *testing.T, _ *wire.BlockHeader, headerBytes []byte, blockVerbose *btcjson.GetBlockVerboseTxResult, outTxid string, tssAddress string, nonce uint64) { // Deserialization should work for each transaction in the block txns := []*btcutil.Tx{} txBodies := [][]byte{} @@ -118,7 +118,7 @@ func validateBitcoinBlock(t *testing.T, header *wire.BlockHeader, headerBytes [] // Validate Tss SegWit transaction if it's an outTx if res.Txid == outTxid { msg := &crosschaintypes.MsgAddToOutTxTracker{ - ChainId: common.BtcChainID(), + ChainId: common.BtcTestNetChain().ChainId, Nonce: nonce, TxHash: outTxid, } diff --git a/common/pubkey.go b/common/pubkey.go index cf020c84ac..db3af5bc54 100644 --- a/common/pubkey.go +++ b/common/pubkey.go @@ -88,29 +88,34 @@ func (pubKey PubKey) String() string { // GetAddress will return an address for the given chain func (pubKey PubKey) GetAddress(chain Chain) (Address, error) { + if IsEVMChain(chain.ChainId) { + return pubKey.GetEVMAddress() + } + return NoAddress, nil +} + +// GetEVMAddress will return the evm address +func (pubKey PubKey) GetEVMAddress() (Address, error) { if pubKey.IsEmpty() { return NoAddress, nil } - if IsEVMChain(chain.ChainId) { - // retrieve compressed pubkey bytes from bechh32 encoded str - pk, err := cosmos.GetPubKeyFromBech32(cosmos.Bech32PubKeyTypeAccPub, string(pubKey)) - if err != nil { - return NoAddress, err - } - // parse compressed bytes removing 5 first bytes (amino encoding) to get uncompressed - pub, err := secp256k1.ParsePubKey(pk.Bytes()) - if err != nil { - return NoAddress, err - } - str := strings.ToLower(eth.PubkeyToAddress(*pub.ToECDSA()).String()) - return NewAddress(str, chain) + // retrieve compressed pubkey bytes from bechh32 encoded str + pk, err := cosmos.GetPubKeyFromBech32(cosmos.Bech32PubKeyTypeAccPub, string(pubKey)) + if err != nil { + return NoAddress, err } - return NoAddress, nil + // parse compressed bytes removing 5 first bytes (amino encoding) to get uncompressed + pub, err := secp256k1.ParsePubKey(pk.Bytes()) + if err != nil { + return NoAddress, err + } + str := strings.ToLower(eth.PubkeyToAddress(*pub.ToECDSA()).String()) + return NewAddress(str), nil } func (pubKey PubKey) GetZetaAddress() (cosmos.AccAddress, error) { - addr, err := pubKey.GetAddress(ZetaChain()) + addr, err := pubKey.GetEVMAddress() if err != nil { return nil, err } diff --git a/common/pubkey_test.go b/common/pubkey_test.go index 2a8a994e82..9b7b0c5ffd 100644 --- a/common/pubkey_test.go +++ b/common/pubkey_test.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package common import ( @@ -107,26 +104,6 @@ func (s *PubKeyTestSuite) TestPubKey(c *C) { c.Assert(pk2.Equals(pk), Equals, true) } -// -//func (s *PubKeyTestSuite) TestPubKeySet(c *C) { -// _, pubKey, _ := testdata.KeyTestPubAddr() -// spk, err := cosmos.Bech32ifyPubKey(cosmos.Bech32PubKeyTypeAccPub, pubKey) -// c.Assert(err, IsNil) -// pk, err := NewPubKey(spk) -// c.Assert(err, IsNil) -// -// c.Check(PubKeySet{}.Contains(pk), Equals, false) -// -// pks := PubKeySet{ -// Secp256k1: pk, -// } -// c.Check(pks.Contains(pk), Equals, true) -// pks = PubKeySet{ -// Ed25519: pk, -// } -// c.Check(pks.Contains(pk), Equals, true) -//} - func (s *PubKeyTestSuite) TestPubKeyGetAddress(c *C) { original := os.Getenv("NET") defer func() { diff --git a/common/tss.go b/common/tss.go new file mode 100644 index 0000000000..e64f206645 --- /dev/null +++ b/common/tss.go @@ -0,0 +1,50 @@ +package common + +import ( + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcutil" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + zcommon "github.com/zeta-chain/zetacore/common/cosmos" +) + +// GetTssAddrEVM returns the ethereum address of the tss pubkey +func GetTssAddrEVM(tssPubkey string) (ethcommon.Address, error) { + var keyAddr ethcommon.Address + pubk, err := zcommon.GetPubKeyFromBech32(zcommon.Bech32PubKeyTypeAccPub, tssPubkey) + if err != nil { + return keyAddr, err + } + //keyAddrBytes := pubk.EVMAddress().Bytes() + pubk.Bytes() + decompresspubkey, err := crypto.DecompressPubkey(pubk.Bytes()) + if err != nil { + return keyAddr, err + } + + keyAddr = crypto.PubkeyToAddress(*decompresspubkey) + + return keyAddr, nil +} + +// GetTssAddrBTC returns the bitcoin address of the tss pubkey +func GetTssAddrBTC(tssPubkey string, bitcoinParams *chaincfg.Params) (string, error) { + addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tssPubkey, bitcoinParams) + if err != nil { + return "", err + } + + return addrWPKH.EncodeAddress(), nil +} + +func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string, bitcoinParams *chaincfg.Params) (*btcutil.AddressWitnessPubKeyHash, error) { + pubk, err := zcommon.GetPubKeyFromBech32(zcommon.Bech32PubKeyTypeAccPub, tssPubkey) + if err != nil { + return nil, err + } + addr, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(pubk.Bytes()), bitcoinParams) + if err != nil { + return nil, err + } + return addr, nil +} diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index 2656fba9ef..dc25371c26 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -30,6 +30,7 @@ services: - "1317:1317" - "9545:8545" - "9546:8546" + - "26657:26657" networks: mynetwork: ipv4_address: 172.20.0.11 diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin index 9b241a147f..f512145bdd 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin @@ -1 +1 @@ -60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033 +60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033 diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go index 2aa91eb530..b02a69f878 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go @@ -26,6 +26,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // Context is an auto generated low-level Go binding around an user-defined struct. @@ -38,7 +39,7 @@ type Context struct { // ZEVMSwapAppMetaData contains all meta data concerning the ZEVMSwapApp contract. var ZEVMSwapAppMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router02_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"systemContract_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSender\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LowAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeMemo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetZRC20\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"}],\"name\":\"encodeMemo\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router02\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"systemContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033", + Bin: "0x60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033", } // ZEVMSwapAppABI is the input ABI used to generate the binding from. @@ -163,11 +164,11 @@ func NewZEVMSwapAppFilterer(address common.Address, filterer bind.ContractFilter // bindZEVMSwapApp binds a generic wrapper to an already deployed contract. func bindZEVMSwapApp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ZEVMSwapAppABI)) + parsed, err := ZEVMSwapAppMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json index ff164359a6..5c803781fa 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json @@ -146,5 +146,5 @@ "type": "function" } ], - "bin": "60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033" + "bin": "60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033" } diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol index 21be9ab61f..e9f098699d 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol @@ -17,42 +17,29 @@ interface zContract { bytes calldata message ) external; } + interface IZRC20 { function totalSupply() external view returns (uint256); - function balanceOf(address account) external view returns (uint256); - function transfer(address recipient, uint256 amount) external returns (bool); - function allowance(address owner, address spender) external view returns (uint256); - function approve(address spender, uint256 amount) external returns (bool); - function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); - function deposit(address to, uint256 amount) external returns (bool); - function burn(address account, uint256 amount) external returns (bool); - function withdraw(bytes memory to, uint256 amount) external returns (bool); - function withdrawGasFee() external view returns (address, uint256); - function PROTOCOL_FEE() external view returns (uint256); - event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Deposit(bytes from, address indexed to, uint256 value); event Withdrawal(address indexed from, bytes to, uint256 value, uint256 gasFee, uint256 protocolFlatFee); } - - - contract ZEVMSwapApp is zContract { error InvalidSender(); error LowAmount(); @@ -67,44 +54,46 @@ contract ZEVMSwapApp is zContract { } function encodeMemo(address targetZRC20, bytes calldata recipient) pure external returns (bytes memory) { -// return abi.encode(targetZRC20, recipient, minAmountOut); return abi.encodePacked(targetZRC20, recipient); } - // data function decodeMemo(bytes calldata data) pure public returns (address, bytes memory) { bytes memory decodedBytes; uint256 size; - size = data.length; address addr; + + size = data.length; addr = address(uint160(bytes20(data[0:20]))); decodedBytes = data[20:]; return (addr, decodedBytes); } - - // Call this function to perform a cross-chain swap + // Perform a cross-chain swap function onCrossChainCall(Context calldata, address zrc20, uint256 amount, bytes calldata message) external override { if (msg.sender != systemContract) { revert InvalidSender(); } + address targetZRC20; bytes memory recipient; - (targetZRC20, recipient) = decodeMemo(message); address[] memory path; + + (targetZRC20, recipient) = decodeMemo(message); path = new address[](2); path[0] = zrc20; path[1] = targetZRC20; - // Approve the usage of this token by router02 + + // approve the usage of this token by router02 IZRC20(zrc20).approve(address(router02), amount); - // Swap for your target token + + // swap for target token uint256[] memory amounts = IUniswapV2Router02(router02).swapExactTokensForTokens(amount, 0, path, address(this), _DEADLINE); - // this contract subsides withdraw gas fee + // perform withdrawal with the target token (address gasZRC20Addr,uint256 gasFee) = IZRC20(targetZRC20).withdrawGasFee(); IZRC20(gasZRC20Addr).approve(address(targetZRC20), gasFee); - IZRC20(targetZRC20).approve(address(targetZRC20), amounts[1]); // this does not seem to be necessary - IZRC20(targetZRC20).withdraw(recipient, amounts[1]-gasFee); + IZRC20(targetZRC20).approve(address(targetZRC20), amounts[1]*10); + IZRC20(targetZRC20).withdraw(recipient, amounts[1]); } } \ No newline at end of file diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go index f87b3878ad..493d7a99c5 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go @@ -1,39 +1,6 @@ -// solc/abigen use version 0.8.7 -//go:generate sh -c " solc --evm-version london --allow-paths .., --combined-json abi,bin --base-path .. ZEVMSwapApp.sol | jq '.contracts.\"ZEVMSwapApp.sol:ZEVMSwapApp\"' > ZEVMSwapApp.json" +//go:generate sh -c "solc --evm-version paris ZEVMSwapApp.sol --combined-json abi,bin --allow-paths .. | jq '.contracts.\"ZEVMSwapApp.sol:ZEVMSwapApp\"' > ZEVMSwapApp.json" //go:generate sh -c "cat ZEVMSwapApp.json | jq .abi > ZEVMSwapApp.abi" //go:generate sh -c "cat ZEVMSwapApp.json | jq .bin | tr -d '\"' > ZEVMSwapApp.bin" - //go:generate sh -c "abigen --abi ZEVMSwapApp.abi --bin ZEVMSwapApp.bin --pkg zevmswap --type ZEVMSwapApp --out ZEVMSwapApp.go" package zevmswap - -import ( - _ "embed" - "encoding/json" - - "github.com/ethereum/go-ethereum/accounts/abi" - evmtypes "github.com/evmos/ethermint/x/evm/types" -) - -type CompiledContract struct { - ABI abi.ABI - Bin evmtypes.HexString -} - -var ( - //go:embed ZEVMSwapApp.json - ZEVMSwapAppJSON []byte // nolint: golint - - ZEVMSwapAppContract CompiledContract -) - -func init() { - err := json.Unmarshal(ZEVMSwapAppJSON, &ZEVMSwapAppContract) - if err != nil { - panic(err) - } - - if len(ZEVMSwapAppContract.Bin) == 0 { - panic("load contract failed") - } -} diff --git a/contrib/localnet/orchestrator/smoketest/contracts/interfaces/IUniswapV2Router01.sol b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/interfaces/IUniswapV2Router01.sol similarity index 100% rename from contrib/localnet/orchestrator/smoketest/contracts/interfaces/IUniswapV2Router01.sol rename to contrib/localnet/orchestrator/smoketest/contracts/zevmswap/interfaces/IUniswapV2Router01.sol diff --git a/contrib/localnet/orchestrator/smoketest/contracts/interfaces/IUniswapV2Router02.sol b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/interfaces/IUniswapV2Router02.sol similarity index 100% rename from contrib/localnet/orchestrator/smoketest/contracts/interfaces/IUniswapV2Router02.sol rename to contrib/localnet/orchestrator/smoketest/contracts/zevmswap/interfaces/IUniswapV2Router02.sol diff --git a/contrib/localnet/orchestrator/smoketest/main.go b/contrib/localnet/orchestrator/smoketest/main.go index ab0c598976..1a7576bfe9 100644 --- a/contrib/localnet/orchestrator/smoketest/main.go +++ b/contrib/localnet/orchestrator/smoketest/main.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -21,21 +18,23 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/contextapp" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" - "github.com/zeta-chain/zetacore/zetaclient/config" "google.golang.org/grpc" ) var ( - ZetaChainID = "athens_101-1" - DeployerAddress = ethcommon.HexToAddress("0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC") + ZetaChainID = "athens_101-1" + DeployerAddress = ethcommon.HexToAddress("0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC") + // DeployerPrivateKey is the private key for the deployer account + // #nosec G101 - used for testing DeployerPrivateKey = "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263" TSSAddress = ethcommon.HexToAddress("0x0Da38EA1B43758F55eB97590D41e244913A00b26") - BTCTSSAddress, _ = btcutil.DecodeAddress("bcrt1q78nlhm7mr7t6z8a93z3y93k75ftppcukt5ayay", config.BitconNetParams) + BTCTSSAddress, _ = btcutil.DecodeAddress("bcrt1q78nlhm7mr7t6z8a93z3y93k75ftppcukt5ayay", common.BitcoinRegnetParams) BigZero = big.NewInt(0) SmokeTestTimeout = 24 * time.Hour // smoke test fails if timeout is reached USDTZRC20Addr = "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" @@ -47,6 +46,9 @@ var ( //SystemContractAddr = "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921" //ZEVMSwapAppAddr = "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + // RPC + zevmRPC = "http://zetacore0:8545" + // FungibleAdminMnemonic is the mnemonic for the admin account of the fungible module //nolint:gosec - disable nosec because this is a test account FungibleAdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" @@ -167,7 +169,13 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { panic(err) } - //Wait for keygen to be completed. ~ height 30 + // deploy system contracts and ZRC20 contracts on ZetaChain + err = DeploySystemContractsAndZRC20(zetaTxServer) + if err != nil { + panic(err) + } + + // wait for keygen to be completed. ~ height 30 for { time.Sleep(5 * time.Second) response, err := cctxClient.LastZetaHeight(context.Background(), &crosschaintypes.QueryLastZetaHeightRequest{}) @@ -185,8 +193,8 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { var zevmClient *ethclient.Client for { time.Sleep(5 * time.Second) - fmt.Printf("dialing zevm client: http://zetacore0:8545\n") - zevmClient, err = ethclient.Dial("http://zetacore0:8545") + fmt.Printf("dialing zevm client: %s\n", zevmRPC) + zevmClient, err = ethclient.Dial(zevmRPC) if err != nil { continue } @@ -231,12 +239,18 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { if err != nil { panic(err) } + receipt := MustWaitForTxReceipt(zevmClient, tx) if receipt.Status != 1 { panic("ZEVMSwapApp deployment failed") } + zevmSwapApp, err := zevmswap.NewZEVMSwapApp(zevmSwapAppAddr, zevmClient) + if err != nil { + panic(err) + } fmt.Printf("ZEVMSwapApp contract address: %s, tx hash: %s\n", zevmSwapAppAddr.Hex(), tx.Hash().Hex()) + smokeTest.ZEVMSwapAppAddr = zevmSwapAppAddr smokeTest.ZEVMSwapApp = zevmSwapApp @@ -266,7 +280,6 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { // temporarily to reduce dev/test cycle turnaround time smokeTest.CheckZRC20ReserveAndSupply() - smokeTest.TestContextUpgrade() smokeTest.TestDepositAndCallRefund() @@ -276,7 +289,6 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { smokeTest.CheckZRC20ReserveAndSupply() smokeTest.TestERC20Withdraw() - //smokeTest.WithdrawBitcoinMultipleTimes(5) smokeTest.CheckZRC20ReserveAndSupply() smokeTest.TestSendZetaOut() @@ -318,9 +330,10 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { smokeTest.TestDepositEtherLiquidityCap() smokeTest.CheckZRC20ReserveAndSupply() - // add your dev test here - smokeTest.TestMyTest() smokeTest.TestBlockHeaders() + //add your dev test here + smokeTest.TestMyTest() + smokeTest.wg.Wait() } diff --git a/contrib/localnet/orchestrator/smoketest/smoketest.go b/contrib/localnet/orchestrator/smoketest/smoketest.go index de9146bb3f..e6040c2e5e 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketest.go +++ b/contrib/localnet/orchestrator/smoketest/smoketest.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -23,13 +20,13 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/contextapp" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/erc20" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" - "github.com/zeta-chain/zetacore/zetaclient/config" ) type SmokeTest struct { @@ -90,24 +87,24 @@ func NewSmokeTest( btcRPCClient *rpcclient.Client, ) *SmokeTest { // query system contract address - systemContractAddr, err := fungibleClient.SystemContract(context.Background(), &fungibletypes.QueryGetSystemContractRequest{}) + systemContractRes, err := fungibleClient.SystemContract(context.Background(), &fungibletypes.QueryGetSystemContractRequest{}) if err != nil { panic(err) } - fmt.Printf("System contract address: %s\n", systemContractAddr) - SystemContract, err := systemcontract.NewSystemContract(HexToAddress(systemContractAddr.SystemContract.SystemContract), zevmClient) + SystemContract, err := systemcontract.NewSystemContract(HexToAddress(systemContractRes.SystemContract.SystemContract), zevmClient) if err != nil { panic(err) } - SystemContractAddr := HexToAddress(systemContractAddr.SystemContract.SystemContract) + systemContractAddr := HexToAddress(systemContractRes.SystemContract.SystemContract) + fmt.Printf("System contract address: %s\n", systemContractAddr) response := &crosschaintypes.QueryGetTssAddressResponse{} for { response, err = cctxClient.GetTssAddress(context.Background(), &crosschaintypes.QueryGetTssAddressRequest{}) if err != nil { fmt.Printf("cctxClient.TSS error %s\n", err.Error()) - fmt.Printf("TSS not ready yet, waiting for TSS to be appear in zetacore netowrk...\n") + fmt.Printf("TSS not ready yet, waiting for TSS to be appear in zetacore network...\n") time.Sleep(5 * time.Second) continue } @@ -115,7 +112,10 @@ func NewSmokeTest( } TSSAddress = ethcommon.HexToAddress(response.Eth) - BTCTSSAddress, _ = btcutil.DecodeAddress(response.Btc, config.BitconNetParams) + BTCTSSAddress, err = btcutil.DecodeAddress(response.Btc, common.BitcoinRegnetParams) + if err != nil { + panic(err) + } fmt.Printf("TSS EthAddress: %s\n TSS BTC address %s\n", response.GetEth(), response.GetBtc()) return &SmokeTest{ @@ -132,6 +132,6 @@ func NewSmokeTest( zevmAuth: zevmAuth, btcRPCClient: btcRPCClient, SystemContract: SystemContract, - SystemContractAddr: SystemContractAddr, + SystemContractAddr: systemContractAddr, } } diff --git a/contrib/localnet/orchestrator/smoketest/test_accounting.go b/contrib/localnet/orchestrator/smoketest/test_accounting.go index dbca006899..cdb3b64060 100644 --- a/contrib/localnet/orchestrator/smoketest/test_accounting.go +++ b/contrib/localnet/orchestrator/smoketest/test_accounting.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -16,13 +13,18 @@ import ( func (sm *SmokeTest) CheckZRC20ReserveAndSupply() { { - tssBal, _ := sm.goerliClient.BalanceAt(context.Background(), TSSAddress, nil) - zrc20Supply, _ := sm.ETHZRC20.TotalSupply(&bind.CallOpts{}) + tssBal, err := sm.goerliClient.BalanceAt(context.Background(), TSSAddress, nil) + if err != nil { + panic(err) + } + zrc20Supply, err := sm.ETHZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } if tssBal.Cmp(zrc20Supply) < 0 { panic(fmt.Sprintf("ETH: TSS balance (%d) < ZRC20 TotalSupply (%d) ", tssBal, zrc20Supply)) - } else { - fmt.Printf("ETH: TSS balance (%d) >= ZRC20 TotalSupply (%d)\n", tssBal, zrc20Supply) } + fmt.Printf("ETH: TSS balance (%d) >= ZRC20 TotalSupply (%d)\n", tssBal, zrc20Supply) } { @@ -36,12 +38,18 @@ func (sm *SmokeTest) CheckZRC20ReserveAndSupply() { btcBalance += utxo.Amount } } - zrc20Supply, _ := sm.BTCZRC20.TotalSupply(&bind.CallOpts{}) + zrc20Supply, err := sm.BTCZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } + // #nosec G701 smoketest - always in range if int64(btcBalance*1e8) < zrc20Supply.Int64() { + // #nosec G701 smoketest - always in range panic(fmt.Sprintf("BTC: TSS Balance (%d) < ZRC20 TotalSupply (%d) ", int64(btcBalance*1e8), zrc20Supply)) - } else { - fmt.Printf("BTC: Balance (%d) >= ZRC20 TotalSupply (%d)\n", int64(btcBalance*1e8), zrc20Supply) } + + // #nosec G701 smoketest - always in range + fmt.Printf("BTC: Balance (%d) >= ZRC20 TotalSupply (%d)\n", int64(btcBalance*1e8), zrc20Supply) } { @@ -49,12 +57,14 @@ func (sm *SmokeTest) CheckZRC20ReserveAndSupply() { if err != nil { panic(err) } - zrc20Supply, _ := sm.USDTZRC20.TotalSupply(&bind.CallOpts{}) + zrc20Supply, err := sm.USDTZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } if usdtBal.Cmp(zrc20Supply) < 0 { panic(fmt.Sprintf("USDT: TSS balance (%d) < ZRC20 TotalSupply (%d) ", usdtBal, zrc20Supply)) - } else { - fmt.Printf("USDT: TSS balance (%d) >= ZRC20 TotalSupply (%d)\n", usdtBal, zrc20Supply) } + fmt.Printf("USDT: TSS balance (%d) >= ZRC20 TotalSupply (%d)\n", usdtBal, zrc20Supply) } { diff --git a/contrib/localnet/orchestrator/smoketest/test_bitcoin.go b/contrib/localnet/orchestrator/smoketest/test_bitcoin.go index 597e806d27..487ff53051 100644 --- a/contrib/localnet/orchestrator/smoketest/test_bitcoin.go +++ b/contrib/localnet/orchestrator/smoketest/test_bitcoin.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -61,7 +58,10 @@ func (sm *SmokeTest) TestBitcoinSetup() { if err != nil { panic(err) } - BTCDeployerAddress, err = btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(privkeyWIF.PrivKey.PubKey().SerializeCompressed()), &chaincfg.RegressionNetParams) + BTCDeployerAddress, err = btcutil.NewAddressWitnessPubKeyHash( + btcutil.Hash160(privkeyWIF.PrivKey.PubKey().SerializeCompressed()), + &chaincfg.RegressionNetParams, + ) if err != nil { panic(err) } @@ -102,7 +102,10 @@ func (sm *SmokeTest) TestBitcoinSetup() { go func() { // keep bitcoin chain going for { - _, _ = btc.GenerateToAddress(4, BTCDeployerAddress, nil) + _, err = btc.GenerateToAddress(4, BTCDeployerAddress, nil) + if err != nil { + fmt.Println(err) + } time.Sleep(5 * time.Second) } }() @@ -128,11 +131,11 @@ func (sm *SmokeTest) DepositBTC() { fmt.Printf(" spendableAmount: %f\n", spendableAmount) fmt.Printf(" spendableUTXOs: %d\n", spendableUTXOs) fmt.Printf("Now sending two txs to TSS address...\n") - txHash_1, err := SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) + txHash1, err := SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) if err != nil { panic(err) } - txHash_2, err := SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) + txHash2, err := SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) if err != nil { panic(err) } @@ -179,8 +182,8 @@ func (sm *SmokeTest) DepositBTC() { // prove the two transactions of the deposit LoudPrintf("Bitcoin Merkle Proof\n") - sm.ProveBTCTransaction(txHash_1) - sm.ProveBTCTransaction(txHash_2) + sm.ProveBTCTransaction(txHash1) + sm.ProveBTCTransaction(txHash2) } func (sm *SmokeTest) ProveBTCTransaction(txHash *chainhash.Hash) { @@ -437,6 +440,8 @@ func (sm *SmokeTest) WithdrawBitcoin() { func (sm *SmokeTest) WithdrawBitcoinMultipleTimes(repeat int64) { totalAmount := big.NewInt(int64(0.1 * 1e8)) + + // #nosec G701 smoketest - always in range amount := big.NewInt(int64(0.1 * 1e8 / float64(repeat))) // check if the deposit is successful @@ -582,11 +587,17 @@ func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXO fmt.Printf(" value: %d\n", txout.Value) fmt.Printf(" PkScript: %x\n", txout.PkScript) } - var inputsForSign []btcjson.RawTxWitnessInput + + inputsForSign := make([]btcjson.RawTxWitnessInput, len(inputs)) for i, input := range inputs { - inputsForSign = append(inputsForSign, btcjson.RawTxWitnessInput{ - Txid: input.Txid, Vout: input.Vout, Amount: &amounts[i], ScriptPubKey: scriptPubkeys[i]}) + inputsForSign[i] = btcjson.RawTxWitnessInput{ + Txid: input.Txid, + Vout: input.Vout, + Amount: &amounts[i], + ScriptPubKey: scriptPubkeys[i], + } } + //stx, signed, err := btc.SignRawTransactionWithWallet(tx) stx, signed, err := btc.SignRawTransactionWithWallet2(tx, inputsForSign) if err != nil { @@ -614,7 +625,13 @@ func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXO panic(err) } - events := zetaclient.FilterAndParseIncomingTx([]btcjson.TxRawResult{*rawtx}, 0, BTCTSSAddress.EncodeAddress(), &log.Logger) + events := zetaclient.FilterAndParseIncomingTx( + []btcjson.TxRawResult{*rawtx}, + 0, + BTCTSSAddress.EncodeAddress(), + &log.Logger, + common.BtcRegtestChain().ChainId, + ) fmt.Printf("bitcoin intx events:\n") for _, event := range events { fmt.Printf(" TxHash: %s\n", event.TxHash) diff --git a/contrib/localnet/orchestrator/smoketest/test_block_headers.go b/contrib/localnet/orchestrator/smoketest/test_block_headers.go index bd0084d891..d0b9749677 100644 --- a/contrib/localnet/orchestrator/smoketest/test_block_headers.go +++ b/contrib/localnet/orchestrator/smoketest/test_block_headers.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -47,10 +44,9 @@ func (sm *SmokeTest) TestBlockHeaders() { } if bn > earliestBlock { panic(fmt.Sprintf("block header tracing failed; expected at most %d, got %d", earliestBlock, bn)) - } else { - fmt.Printf("block header tracing succeeded; expected at most %d, got %d\n", earliestBlock, bn) } + fmt.Printf("block header tracing succeeded; expected at most %d, got %d\n", earliestBlock, bn) } - checkBlock(common.GoerliChain().ChainId) + checkBlock(common.GoerliLocalnetChain().ChainId) checkBlock(common.BtcRegtestChain().ChainId) } diff --git a/contrib/localnet/orchestrator/smoketest/test_context.go b/contrib/localnet/orchestrator/smoketest/test_context.go index 091336daa5..5f7a82cd5c 100644 --- a/contrib/localnet/orchestrator/smoketest/test_context.go +++ b/contrib/localnet/orchestrator/smoketest/test_context.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( diff --git a/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go b/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go index 7e40cb8084..b973ab37b7 100644 --- a/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go +++ b/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -85,7 +82,10 @@ func (sm *SmokeTest) TestCrosschainSwap() { } receipt = MustWaitForTxReceipt(sm.zevmClient, tx) fmt.Printf(" USDT ZRC20 transfer receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) - bal1, _ := sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.ZEVMSwapAppAddr) + bal1, err := sm.ETHZRC20.BalanceOf(&bind.CallOpts{}, sm.ZEVMSwapAppAddr) + if err != nil { + panic(err) + } fmt.Printf(" ZEVMSwapApp ETHZRC20 balance %d", bal1) tx, err = sm.BTCZRC20.Transfer(sm.zevmAuth, sm.ZEVMSwapAppAddr, big.NewInt(1e6)) if err != nil { @@ -93,7 +93,10 @@ func (sm *SmokeTest) TestCrosschainSwap() { } receipt = MustWaitForTxReceipt(sm.zevmClient, tx) fmt.Printf(" BTC ZRC20 transfer receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) - bal2, _ := sm.BTCZRC20.BalanceOf(&bind.CallOpts{}, sm.ZEVMSwapAppAddr) + bal2, err := sm.BTCZRC20.BalanceOf(&bind.CallOpts{}, sm.ZEVMSwapAppAddr) + if err != nil { + panic(err) + } fmt.Printf(" ZEVMSwapApp BTCZRC20 balance %d", bal2) // msg would be [ZEVMSwapAppAddr, memobytes] @@ -113,13 +116,23 @@ func (sm *SmokeTest) TestCrosschainSwap() { txhash = sm.DepositERC20(big.NewInt(8e7), msg) cctx1 := WaitCctxMinedByInTxHash(txhash.Hex(), sm.cctxClient) + // check the cctx status + if cctx1.CctxStatus.Status != types.CctxStatus_OutboundMined { + panic(fmt.Sprintf("expected outbound mined status; got %s, message: %s", cctx1.CctxStatus.Status.String(), cctx1.CctxStatus.StatusMessage)) + } + _, err = sm.btcRPCClient.GenerateToAddress(10, BTCDeployerAddress, nil) if err != nil { panic(err) } // cctx1 index acts like the inTxHash for the second cctx (the one that withdraws BTC) cctx2 := WaitCctxMinedByInTxHash(cctx1.Index, sm.cctxClient) - _ = cctx2 + + // check the cctx status + if cctx2.CctxStatus.Status != types.CctxStatus_OutboundMined { + panic(fmt.Sprintf("expected outbound mined status; got %s, message: %s", cctx2.CctxStatus.Status.String(), cctx2.CctxStatus.StatusMessage)) + } + fmt.Printf("cctx2 outbound tx hash %s\n", cctx2.GetCurrentOutTxParam().OutboundTxHash) fmt.Printf("******* Second test: BTC -> USDT\n") @@ -129,6 +142,7 @@ func (sm *SmokeTest) TestCrosschainSwap() { } fmt.Printf("#utxos %d\n", len(utxos)) //fmt.Printf("Unimplemented!\n") + fmt.Printf("memo address %s\n", sm.USDTZRC20Addr) memo, err := sm.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, sm.USDTZRC20Addr, DeployerAddress.Bytes()) if err != nil { panic(err) @@ -172,6 +186,9 @@ func (sm *SmokeTest) TestCrosschainSwap() { amount := 0.1 txid, err := SendToTSSFromDeployerWithMemo(BTCTSSAddress, amount, utxos[0:2], sm.btcRPCClient, memo) + if err != nil { + panic(err) + } fmt.Printf("Sent BTC to TSS txid %s; now mining 10 blocks for confirmation\n", txid) _, err = sm.btcRPCClient.GenerateToAddress(10, BTCDeployerAddress, nil) if err != nil { diff --git a/contrib/localnet/orchestrator/smoketest/test_deposit_eth.go b/contrib/localnet/orchestrator/smoketest/test_deposit_eth.go index a792957410..3b1194ff9a 100644 --- a/contrib/localnet/orchestrator/smoketest/test_deposit_eth.go +++ b/contrib/localnet/orchestrator/smoketest/test_deposit_eth.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -48,10 +45,13 @@ func (sm *SmokeTest) TestDepositEtherIntoZRC20() { if err != nil { panic(err) } - ethZRC20Addr, err := systemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.GoerliChain().ChainId)) + ethZRC20Addr, err := systemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.GoerliLocalnetChain().ChainId)) if err != nil { panic(err) } + if (ethZRC20Addr == ethcommon.Address{}) { + panic("eth zrc20 not found") + } sm.ETHZRC20Addr = ethZRC20Addr fmt.Printf("eth zrc20 address: %s\n", ethZRC20Addr.String()) ethZRC20, err := zrc20.NewZRC20(ethZRC20Addr, sm.zevmClient) @@ -82,6 +82,8 @@ func (sm *SmokeTest) TestDepositEtherIntoZRC20() { LoudPrintf("Merkle Proof\n") txHash := receipt.TxHash blockHash := receipt.BlockHash + + // #nosec G701 smoketest - always in range txIndex := int(receipt.TransactionIndex) block, err := sm.goerliClient.BlockByHash(context.Background(), blockHash) @@ -128,7 +130,7 @@ func (sm *SmokeTest) TestDepositEtherIntoZRC20() { TxIndex: int64(txIndex), TxHash: txHash.Hex(), Proof: common.NewEthereumProof(txProof), - ChainId: common.GoerliChain().ChainId, + ChainId: common.GoerliLocalnetChain().ChainId, }) if err != nil { panic(err) @@ -152,7 +154,13 @@ func (sm *SmokeTest) TestDepositEtherIntoZRC20() { sm.wg.Add(1) go func() { defer sm.wg.Done() - WaitCctxMinedByInTxHash(signedTx.Hash().Hex(), sm.cctxClient) + cctx := WaitCctxMinedByInTxHash(signedTx.Hash().Hex(), sm.cctxClient) + if cctx.CctxStatus.Status != types.CctxStatus_OutboundMined { + panic(fmt.Sprintf("expected cctx status to be mined; got %s, message: %s", + cctx.CctxStatus.Status.String(), + cctx.CctxStatus.StatusMessage), + ) + } c <- 0 }() sm.wg.Add(1) @@ -505,7 +513,7 @@ func (sm *SmokeTest) TestDepositEtherLiquidityCap() { fmt.Println("New deposit succeeded") } -func (sm *SmokeTest) SendEther(to ethcommon.Address, value *big.Int, data []byte) (*ethtypes.Transaction, error) { +func (sm *SmokeTest) SendEther(_ ethcommon.Address, value *big.Int, data []byte) (*ethtypes.Transaction, error) { goerliClient := sm.goerliClient nonce, err := goerliClient.PendingNonceAt(context.Background(), DeployerAddress) diff --git a/contrib/localnet/orchestrator/smoketest/test_erc20.go b/contrib/localnet/orchestrator/smoketest/test_erc20.go deleted file mode 100644 index 309916c3de..0000000000 --- a/contrib/localnet/orchestrator/smoketest/test_erc20.go +++ /dev/null @@ -1,194 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package main - -import ( - "context" - "fmt" - "math/big" - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethcommon "github.com/ethereum/go-ethereum/common" - zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/erc20" -) - -func (sm *SmokeTest) TestERC20Deposit() { - startTime := time.Now() - defer func() { - fmt.Printf("test finishes in %s\n", time.Since(startTime)) - }() - LoudPrintf("Deposit USDT ERC20 into ZEVM\n") - - initialBal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) - if err != nil { - panic(err) - } - txhash := sm.DepositERC20(big.NewInt(1e9), []byte{}) - WaitCctxMinedByInTxHash(txhash.Hex(), sm.cctxClient) - - bal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) - if err != nil { - panic(err) - } - - diff := big.NewInt(0) - diff.Sub(bal, initialBal) - - fmt.Printf("balance of deployer on USDT ZRC20: %d\n", bal) - supply, err := sm.USDTZRC20.TotalSupply(&bind.CallOpts{}) - if err != nil { - panic(err) - } - fmt.Printf("supply of USDT ZRC20: %d\n", supply) - if diff.Int64() != 1e9 { - panic("balance is not correct") - } -} - -func (sm *SmokeTest) DepositERC20(amount *big.Int, msg []byte) ethcommon.Hash { - USDT := sm.USDTERC20 - tx, err := USDT.Mint(sm.goerliAuth, big.NewInt(1e10)) - if err != nil { - panic(err) - } - receipt := MustWaitForTxReceipt(sm.goerliClient, tx) - fmt.Printf("Mint receipt tx hash: %s\n", tx.Hash().Hex()) - - tx, err = USDT.Approve(sm.goerliAuth, sm.ERC20CustodyAddr, big.NewInt(1e10)) - if err != nil { - panic(err) - } - receipt = MustWaitForTxReceipt(sm.goerliClient, tx) - fmt.Printf("USDT Approve receipt tx hash: %s\n", tx.Hash().Hex()) - - tx, err = sm.ERC20Custody.Deposit(sm.goerliAuth, DeployerAddress.Bytes(), sm.USDTERC20Addr, amount, msg) - if err != nil { - panic(err) - } - receipt = MustWaitForTxReceipt(sm.goerliClient, tx) - if receipt.Status == 0 { - panic("deposit failed") - } - fmt.Printf("Deposit receipt tx hash: %s, status %d\n", receipt.TxHash.Hex(), receipt.Status) - for _, log := range receipt.Logs { - event, err := sm.ERC20Custody.ParseDeposited(*log) - if err != nil { - continue - } - fmt.Printf("Deposited event: \n") - fmt.Printf(" Recipient address: %x, \n", event.Recipient) - fmt.Printf(" ERC20 address: %s, \n", event.Asset.Hex()) - fmt.Printf(" Amount: %d, \n", event.Amount) - fmt.Printf(" Message: %x, \n", event.Message) - } - fmt.Printf("gas limit %d\n", sm.zevmAuth.GasLimit) - return tx.Hash() -} - -func (sm *SmokeTest) TestERC20Withdraw() { - startTime := time.Now() - defer func() { - fmt.Printf("test finishes in %s\n", time.Since(startTime)) - }() - LoudPrintf("Withdraw USDT ZRC20\n") - sm.WithdrawERC20() -} - -func (sm *SmokeTest) WithdrawERC20() { - zevmClient := sm.zevmClient - goerliClient := sm.goerliClient - cctxClient := sm.cctxClient - - usdtZRC20, err := zrc20.NewZRC20(ethcommon.HexToAddress(USDTZRC20Addr), zevmClient) - if err != nil { - panic(err) - } - bal, err := usdtZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) - if err != nil { - panic(err) - } - fmt.Printf("balance of deployer on USDT ZRC20: %d\n", bal) - supply, err := usdtZRC20.TotalSupply(&bind.CallOpts{}) - if err != nil { - panic(err) - } - fmt.Printf("supply of USDT ZRC20: %d\n", supply) - - gasZRC20, gasFee, err := usdtZRC20.WithdrawGasFee(&bind.CallOpts{}) - if err != nil { - panic(err) - } - fmt.Printf("gasZRC20: %s, gasFee: %d\n", gasZRC20.Hex(), gasFee) - - ethZRC20, err := zrc20.NewZRC20(gasZRC20, zevmClient) - if err != nil { - panic(err) - } - bal, err = ethZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) - if err != nil { - panic(err) - } - fmt.Printf("balance of deployer on ETH ZRC20: %d\n", bal) - if bal.Int64() <= 0 { - panic("not enough ETH ZRC20 balance!") - } - - // Approve - tx, err := ethZRC20.Approve(sm.zevmAuth, ethcommon.HexToAddress(USDTZRC20Addr), big.NewInt(1e18)) - if err != nil { - panic(err) - } - receipt := MustWaitForTxReceipt(zevmClient, tx) - fmt.Printf("eth zrc20 approve receipt: status %d\n", receipt.Status) - // Withdraw - tx, err = usdtZRC20.Withdraw(sm.zevmAuth, DeployerAddress.Bytes(), big.NewInt(100)) - if err != nil { - panic(err) - } - receipt = MustWaitForTxReceipt(zevmClient, tx) - fmt.Printf("Receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) - for _, log := range receipt.Logs { - event, err := usdtZRC20.ParseWithdrawal(*log) - if err != nil { - continue - } - fmt.Printf(" logs: from %s, to %x, value %d, gasfee %d\n", event.From.Hex(), event.To, event.Value, event.Gasfee) - } - - sm.wg.Add(1) - go func() { - defer sm.wg.Done() - cctx := WaitCctxMinedByInTxHash(receipt.TxHash.Hex(), cctxClient) - fmt.Printf("outTx hash %s\n", cctx.GetCurrentOutTxParam().OutboundTxHash) - - USDTERC20, err := erc20.NewUSDT(ethcommon.HexToAddress(USDTERC20Addr), goerliClient) - if err != nil { - panic(err) - } - bal, err = USDTERC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) - if err != nil { - panic(err) - } - fmt.Printf("USDT ERC20 bal: %d\n", bal) - - receipt, err := sm.goerliClient.TransactionReceipt(context.Background(), ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) - if err != nil { - panic(err) - } - fmt.Printf("Receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) - for _, log := range receipt.Logs { - event, err := USDTERC20.ParseTransfer(*log) - if err != nil { - continue - } - fmt.Printf(" logs: from %s, to %s, value %d\n", event.From.Hex(), event.To.Hex(), event.Value) - if event.Value.Int64() != 100 { - panic("value is not correct") - } - } - }() - sm.wg.Wait() -} diff --git a/contrib/localnet/orchestrator/smoketest/test_erc20_deposit.go b/contrib/localnet/orchestrator/smoketest/test_erc20_deposit.go new file mode 100644 index 0000000000..49c84a9fff --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/test_erc20_deposit.go @@ -0,0 +1,159 @@ +package main + +import ( + "fmt" + "math/big" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethcommon "github.com/ethereum/go-ethereum/common" + testcontract "github.com/zeta-chain/zetacore/testutil/contracts" +) + +func (sm *SmokeTest) TestERC20Deposit() { + startTime := time.Now() + defer func() { + fmt.Printf("test finishes in %s\n", time.Since(startTime)) + }() + LoudPrintf("Deposit USDT ERC20 into ZEVM\n") + + initialBal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + txhash := sm.DepositERC20(big.NewInt(1e18), []byte{}) + WaitCctxMinedByInTxHash(txhash.Hex(), sm.cctxClient) + + bal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + + diff := big.NewInt(0) + diff.Sub(bal, initialBal) + + fmt.Printf("balance of deployer on USDT ZRC20: %d\n", bal) + supply, err := sm.USDTZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } + fmt.Printf("supply of USDT ZRC20: %d\n", supply) + if diff.Int64() != 1e18 { + panic("balance is not correct") + } + + LoudPrintf("Same-transaction multiple deposit USDT ERC20 into ZEVM\n") + initialBal, err = sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + txhash = sm.MultipleDeposits(big.NewInt(1e9), big.NewInt(10)) + cctxs := WaitCctxsMinedByInTxHash(txhash.Hex(), sm.cctxClient, 10) + if len(cctxs) != 10 { + panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs))) + } + + // check new balance is increased by 1e9 * 10 + bal, err = sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + diff = big.NewInt(0).Sub(bal, initialBal) + if diff.Int64() != 1e10 { + panic(fmt.Sprintf("balance difference is not correct: %d", diff.Int64())) + } +} + +func (sm *SmokeTest) DepositERC20(amount *big.Int, msg []byte) ethcommon.Hash { + USDT := sm.USDTERC20 + tx, err := USDT.Mint(sm.goerliAuth, amount) + if err != nil { + panic(err) + } + receipt := MustWaitForTxReceipt(sm.goerliClient, tx) + fmt.Printf("Mint receipt tx hash: %s\n", tx.Hash().Hex()) + + tx, err = USDT.Approve(sm.goerliAuth, sm.ERC20CustodyAddr, amount) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.goerliClient, tx) + fmt.Printf("USDT Approve receipt tx hash: %s\n", tx.Hash().Hex()) + + tx, err = sm.ERC20Custody.Deposit(sm.goerliAuth, DeployerAddress.Bytes(), sm.USDTERC20Addr, amount, msg) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.goerliClient, tx) + if receipt.Status == 0 { + panic("deposit failed") + } + fmt.Printf("Deposit receipt tx hash: %s, status %d\n", receipt.TxHash.Hex(), receipt.Status) + for _, log := range receipt.Logs { + event, err := sm.ERC20Custody.ParseDeposited(*log) + if err != nil { + continue + } + fmt.Printf("Deposited event: \n") + fmt.Printf(" Recipient address: %x, \n", event.Recipient) + fmt.Printf(" ERC20 address: %s, \n", event.Asset.Hex()) + fmt.Printf(" Amount: %d, \n", event.Amount) + fmt.Printf(" Message: %x, \n", event.Message) + } + fmt.Printf("gas limit %d\n", sm.zevmAuth.GasLimit) + return tx.Hash() +} + +func (sm *SmokeTest) MultipleDeposits(amount, count *big.Int) ethcommon.Hash { + // deploy depositor + depositorAddr, _, depositor, err := testcontract.DeployDepositor(sm.goerliAuth, sm.goerliClient, sm.ERC20CustodyAddr) + if err != nil { + panic(err) + } + + fullAmount := big.NewInt(0).Mul(amount, count) + + // mint + tx, err := sm.USDTERC20.Mint(sm.goerliAuth, fullAmount) + if err != nil { + panic(err) + } + receipt := MustWaitForTxReceipt(sm.goerliClient, tx) + if receipt.Status == 0 { + panic("mint failed") + } + fmt.Printf("Mint receipt tx hash: %s\n", tx.Hash().Hex()) + + // approve + tx, err = sm.USDTERC20.Approve(sm.goerliAuth, depositorAddr, fullAmount) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.goerliClient, tx) + if receipt.Status == 0 { + panic("approve failed") + } + fmt.Printf("USDT Approve receipt tx hash: %s\n", tx.Hash().Hex()) + + // deposit + tx, err = depositor.RunDeposits(sm.goerliAuth, DeployerAddress.Bytes(), sm.USDTERC20Addr, amount, []byte{}, count) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.goerliClient, tx) + if receipt.Status == 0 { + panic("deposits failed") + } + fmt.Printf("Deposits receipt tx hash: %s\n", tx.Hash().Hex()) + + for _, log := range receipt.Logs { + event, err := sm.ERC20Custody.ParseDeposited(*log) + if err != nil { + continue + } + fmt.Printf("Multiple deposit event: \n") + fmt.Printf(" Amount: %d, \n", event.Amount) + } + fmt.Printf("gas limit %d\n", sm.zevmAuth.GasLimit) + return tx.Hash() +} diff --git a/contrib/localnet/orchestrator/smoketest/test_erc20_refund.go b/contrib/localnet/orchestrator/smoketest/test_erc20_refund.go index e8d5686313..8deb02bdc6 100644 --- a/contrib/localnet/orchestrator/smoketest/test_erc20_refund.go +++ b/contrib/localnet/orchestrator/smoketest/test_erc20_refund.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -151,7 +148,7 @@ func (sm *SmokeTest) createZetaERC20LiquidityPool() error { } receipt = MustWaitForTxReceipt(sm.zevmClient, tx) if receipt.Status == 0 { - return errors.New("add liquidity failed") + return fmt.Errorf("add liquidity failed") } return nil diff --git a/contrib/localnet/orchestrator/smoketest/test_erc20_withdraw.go b/contrib/localnet/orchestrator/smoketest/test_erc20_withdraw.go new file mode 100644 index 0000000000..821954e4ee --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/test_erc20_withdraw.go @@ -0,0 +1,178 @@ +package main + +import ( + "context" + "fmt" + "math/big" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethcommon "github.com/ethereum/go-ethereum/common" + zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" + "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/erc20" + testcontract "github.com/zeta-chain/zetacore/testutil/contracts" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func (sm *SmokeTest) TestERC20Withdraw() { + startTime := time.Now() + defer func() { + fmt.Printf("test finishes in %s\n", time.Since(startTime)) + }() + + bal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + fmt.Printf("balance of deployer on USDT ZRC20: %d\n", bal) + supply, err := sm.USDTZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } + fmt.Printf("supply of USDT ZRC20: %d\n", supply) + + gasZRC20, gasFee, err := sm.USDTZRC20.WithdrawGasFee(&bind.CallOpts{}) + if err != nil { + panic(err) + } + fmt.Printf("gasZRC20: %s, gasFee: %d\n", gasZRC20.Hex(), gasFee) + + ethZRC20, err := zrc20.NewZRC20(gasZRC20, sm.zevmClient) + if err != nil { + panic(err) + } + bal, err = ethZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + fmt.Printf("balance of deployer on ETH ZRC20: %d\n", bal) + if bal.Int64() <= 0 { + panic("not enough ETH ZRC20 balance!") + } + + LoudPrintf("Withdraw USDT ZRC20\n") + sm.WithdrawERC20(ethZRC20) + + LoudPrintf("Multiple withdraws USDT ZRC20\n") + sm.MultipleWithdraws(ethZRC20) +} + +func (sm *SmokeTest) WithdrawERC20(ethZRC20 *zrc20.ZRC20) { + // approve + tx, err := ethZRC20.Approve(sm.zevmAuth, ethcommon.HexToAddress(USDTZRC20Addr), big.NewInt(1e18)) + if err != nil { + panic(err) + } + receipt := MustWaitForTxReceipt(sm.zevmClient, tx) + if receipt.Status == 0 { + panic("approve failed") + } + fmt.Printf("eth zrc20 approve receipt: status %d\n", receipt.Status) + + // withdraw + tx, err = sm.USDTZRC20.Withdraw(sm.zevmAuth, DeployerAddress.Bytes(), big.NewInt(100)) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.zevmClient, tx) + fmt.Printf("Receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) + for _, log := range receipt.Logs { + event, err := sm.USDTZRC20.ParseWithdrawal(*log) + if err != nil { + continue + } + fmt.Printf(" logs: from %s, to %x, value %d, gasfee %d\n", event.From.Hex(), event.To, event.Value, event.Gasfee) + } + + // verify the withdraw value + cctx := WaitCctxMinedByInTxHash(receipt.TxHash.Hex(), sm.cctxClient) + sm.verifyTransferAmountFromCCTX(cctx, 100) +} + +func (sm *SmokeTest) MultipleWithdraws(ethZRC20 *zrc20.ZRC20) { + // deploy withdrawer + withdrawerAddr, _, withdrawer, err := testcontract.DeployWithdrawer(sm.zevmAuth, sm.zevmClient) + if err != nil { + panic(err) + } + + // approve + tx, err := sm.USDTZRC20.Approve(sm.zevmAuth, withdrawerAddr, big.NewInt(1e18)) + if err != nil { + panic(err) + } + receipt := MustWaitForTxReceipt(sm.zevmClient, tx) + if receipt.Status == 0 { + panic("approve failed") + } + fmt.Printf("USDT ZRC20 approve receipt: status %d\n", receipt.Status) + + // approve gas token + tx, err = ethZRC20.Approve(sm.zevmAuth, withdrawerAddr, big.NewInt(1e18)) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.zevmClient, tx) + if receipt.Status == 0 { + panic("approve gas token failed") + } + fmt.Printf("eth zrc20 approve receipt: status %d\n", receipt.Status) + + // check the balance + bal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, DeployerAddress) + if err != nil { + panic(err) + } + fmt.Printf("balance of deployer on USDT ZRC20: %d\n", bal) + + if bal.Int64() < 1000 { + panic("not enough USDT ZRC20 balance!") + } + + // withdraw + tx, err = withdrawer.RunWithdraws(sm.zevmAuth, DeployerAddress.Bytes(), sm.USDTZRC20Addr, big.NewInt(100), big.NewInt(10)) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.zevmClient, tx) + if receipt.Status == 0 { + panic("withdraw failed") + } + fmt.Printf("Withdraws receipt: status %d\n", receipt.Status) + + cctxs := WaitCctxsMinedByInTxHash(tx.Hash().Hex(), sm.cctxClient, 10) + if len(cctxs) != 10 { + panic(fmt.Sprintf("cctxs length is not correct: %d", len(cctxs))) + } + + // verify the withdraw value + for _, cctx := range cctxs { + sm.verifyTransferAmountFromCCTX(cctx, 100) + } +} + +// verifyTransferAmountFromCCTX verifies the transfer amount from the CCTX on Goerli +func (sm *SmokeTest) verifyTransferAmountFromCCTX(cctx *crosschaintypes.CrossChainTx, amount int64) { + fmt.Printf("outTx hash %s\n", cctx.GetCurrentOutTxParam().OutboundTxHash) + + USDTERC20, err := erc20.NewUSDT(ethcommon.HexToAddress(USDTERC20Addr), sm.goerliClient) + if err != nil { + panic(err) + } + + receipt, err := sm.goerliClient.TransactionReceipt(context.Background(), ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + fmt.Printf("Receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) + for _, log := range receipt.Logs { + event, err := USDTERC20.ParseTransfer(*log) + if err != nil { + continue + } + fmt.Printf(" logs: from %s, to %s, value %d\n", event.From.Hex(), event.To.Hex(), event.Value) + if event.Value.Int64() != amount { + panic("value is not correct") + } + } +} diff --git a/contrib/localnet/orchestrator/smoketest/test_message_passing.go b/contrib/localnet/orchestrator/smoketest/test_message_passing.go index c4f0f93da7..6be082be30 100644 --- a/contrib/localnet/orchestrator/smoketest/test_message_passing.go +++ b/contrib/localnet/orchestrator/smoketest/test_message_passing.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( diff --git a/contrib/localnet/orchestrator/smoketest/test_mytest.go b/contrib/localnet/orchestrator/smoketest/test_mytest.go index 70a6529224..6f4c16472c 100644 --- a/contrib/localnet/orchestrator/smoketest/test_mytest.go +++ b/contrib/localnet/orchestrator/smoketest/test_mytest.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( diff --git a/contrib/localnet/orchestrator/smoketest/test_pause_zrc20.go b/contrib/localnet/orchestrator/smoketest/test_pause_zrc20.go index f0d0f43c8b..f313ed8ad0 100644 --- a/contrib/localnet/orchestrator/smoketest/test_pause_zrc20.go +++ b/contrib/localnet/orchestrator/smoketest/test_pause_zrc20.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -11,6 +8,7 @@ import ( "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/vault" "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -67,9 +65,8 @@ func (sm *SmokeTest) TestPauseZRC20() { } if !fcRes.GetForeignCoins().Paused { panic("ETH should be paused") - } else { - fmt.Printf("ETH is paused\n") } + fmt.Printf("ETH is paused\n") // Try operations with ETH ZRC20 fmt.Println("Can no longer do operations on ETH ZRC20") @@ -91,7 +88,7 @@ func (sm *SmokeTest) TestPauseZRC20() { } // Operation on a contract that interact with ETH ZRC20 should fail - fmt.Println("Vault contract can no longer interact with ETH ZRC20") + fmt.Printf("Vault contract can no longer interact with ETH ZRC20: %s\n", sm.ETHZRC20Addr.Hex()) tx, err = vaultContract.Deposit(sm.zevmAuth, sm.ETHZRC20Addr, big.NewInt(1e5)) if err != nil { panic(err) @@ -121,6 +118,21 @@ func (sm *SmokeTest) TestPauseZRC20() { panic("BTC vault deposit should succeed") } + // Check deposit revert when paused + signedTx, err := sm.SendEther(TSSAddress, big.NewInt(1e17), nil) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(sm.goerliClient, signedTx) + if receipt.Status == 0 { + panic("deposit eth tx failed") + } + cctx := WaitCctxMinedByInTxHash(signedTx.Hash().Hex(), sm.cctxClient) + if cctx.CctxStatus.Status != types.CctxStatus_Reverted { + panic(fmt.Sprintf("expected cctx status to be Reverted; got %s", cctx.CctxStatus.Status)) + } + fmt.Println("CCTX has been reverted") + // Unpause ETH ZRC20 fmt.Println("Unpausing ETH") msg = fungibletypes.NewMsgUpdateZRC20PausedStatus( @@ -143,9 +155,8 @@ func (sm *SmokeTest) TestPauseZRC20() { } if fcRes.GetForeignCoins().Paused { panic("ETH should be unpaused") - } else { - fmt.Printf("ETH is unpaused\n") } + fmt.Printf("ETH is unpaused\n") // Try operations with ETH ZRC20 fmt.Println("Can do operations on ETH ZRC20 again") diff --git a/contrib/localnet/orchestrator/smoketest/test_setup.go b/contrib/localnet/orchestrator/smoketest/test_setup.go index 1a77089023..1a670febdf 100644 --- a/contrib/localnet/orchestrator/smoketest/test_setup.go +++ b/contrib/localnet/orchestrator/smoketest/test_setup.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -160,7 +157,7 @@ func (sm *SmokeTest) TestSetupZetaTokenAndConnectorAndZEVMContracts() { } fmt.Printf("USDT ZRC20 Address: %s\n", zrc20addr) if HexToAddress(zrc20addr) != HexToAddress(USDTZRC20Addr) { - panic("mismatch of foreign coin USDT ZRC20 and the USDTZRC20Addr constant in smoketest") + panic(fmt.Sprintf("mismatch of foreign coin USDT ZRC20 %s and the USDTZRC20Addr constant %s in smoketest", zrc20addr, USDTZRC20Addr)) } sm.USDTZRC20Addr = ethcommon.HexToAddress(zrc20addr) @@ -197,7 +194,7 @@ func (sm *SmokeTest) TestSetupZetaTokenAndConnectorAndZEVMContracts() { if err != nil { panic(err) } - err = os.WriteFile(ContractsConfigFile, b, 0666) + err = os.WriteFile(ContractsConfigFile, b, 0600) if err != nil { panic(err) } @@ -205,7 +202,7 @@ func (sm *SmokeTest) TestSetupZetaTokenAndConnectorAndZEVMContracts() { // Set existing deployed contracts func (sm *SmokeTest) setContracts() { - err := error(nil) + var err error var contracts Contracts // Read contracts toml file @@ -218,7 +215,7 @@ func (sm *SmokeTest) setContracts() { panic(err) } - //Set ZetaEthAddr + // Set ZetaEthAddr sm.ZetaEthAddr = ethcommon.HexToAddress(contracts.ZetaEthAddress) fmt.Println("Connector Eth address: ", contracts.ZetaEthAddress) sm.ZetaEth, err = zetaeth.NewZetaEth(sm.ZetaEthAddr, sm.goerliClient) @@ -226,42 +223,42 @@ func (sm *SmokeTest) setContracts() { panic(err) } - //Set ConnectorEthAddr + // Set ConnectorEthAddr sm.ConnectorEthAddr = ethcommon.HexToAddress(contracts.ConnectorEthAddr) sm.ConnectorEth, err = zetaconnectoreth.NewZetaConnectorEth(sm.ConnectorEthAddr, sm.goerliClient) if err != nil { panic(err) } - //Set ERC20CustodyAddr + // Set ERC20CustodyAddr sm.ERC20CustodyAddr = ethcommon.HexToAddress(ERC20CustodyAddr) sm.ERC20Custody, err = erc20custody.NewERC20Custody(sm.ERC20CustodyAddr, sm.goerliClient) if err != nil { panic(err) } - //Set USDTERC20Addr + // Set USDTERC20Addr sm.USDTERC20Addr = ethcommon.HexToAddress(USDTERC20Addr) sm.USDTERC20, err = erc20.NewUSDT(sm.USDTERC20Addr, sm.goerliClient) if err != nil { panic(err) } - //Set USDTZRC20Addr + // Set USDTZRC20Addr sm.USDTZRC20Addr = ethcommon.HexToAddress(USDTZRC20Addr) sm.USDTZRC20, err = zrc20.NewZRC20(sm.USDTZRC20Addr, sm.zevmClient) if err != nil { panic(err) } - //UniswapV2FactoryAddr + // UniswapV2FactoryAddr sm.UniswapV2FactoryAddr = ethcommon.HexToAddress(UniswapV2FactoryAddr) sm.UniswapV2Factory, err = uniswapv2factory.NewUniswapV2Factory(sm.UniswapV2FactoryAddr, sm.zevmClient) if err != nil { panic(err) } - //UniswapV2RouterAddr + // UniswapV2RouterAddr sm.UniswapV2RouterAddr = ethcommon.HexToAddress(UniswapV2RouterAddr) sm.UniswapV2Router, err = uniswapv2router.NewUniswapV2Router02(sm.UniswapV2RouterAddr, sm.zevmClient) if err != nil { diff --git a/contrib/localnet/orchestrator/smoketest/test_stress.go b/contrib/localnet/orchestrator/smoketest/test_stress.go index 02a424450d..502d7f7029 100644 --- a/contrib/localnet/orchestrator/smoketest/test_stress.go +++ b/contrib/localnet/orchestrator/smoketest/test_stress.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -20,8 +17,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/spf13/cobra" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - "github.com/zeta-chain/zetacore/x/crosschain/types" - types2 "github.com/zeta-chain/zetacore/x/crosschain/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc" @@ -58,7 +54,7 @@ func init() { RootCmd.AddCommand(StressCmd) StressCmd.Flags().StringVar(&stressTestArgs.ethURL, "ethURL", "http://eth:8545", "--ethURL http://eth:8545") StressCmd.Flags().StringVar(&stressTestArgs.grpcURL, "grpcURL", "zetacore0:9090", "--grpcURL zetacore0:9090") - StressCmd.Flags().StringVar(&stressTestArgs.zevmURL, "zevmURL", "http://zetacore0:8545", "--zevmURL http://zetacore0:8545") + StressCmd.Flags().StringVar(&stressTestArgs.zevmURL, "zevmURL", zevmRPC, "--zevmURL http://zetacore0:8545") StressCmd.Flags().StringVar(&stressTestArgs.deployerAddress, "addr", "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC", "--addr ") StressCmd.Flags().StringVar(&stressTestArgs.deployerPrivateKey, "privKey", "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263", "--privKey ") StressCmd.Flags().StringVar(&stressTestArgs.network, "network", "PRIVNET", "--network PRIVNET") @@ -90,6 +86,9 @@ func StressTest(_ *cobra.Command, _ []string) { fmt.Printf("Deployer address: %s, balance: %d Wei\n", DeployerAddress.Hex(), bal) chainid, err := goerliClient.ChainID(context.Background()) + if err != nil { + panic(err) + } deployerPrivkey, err := crypto.HexToECDSA(stressTestArgs.deployerPrivateKey) if err != nil { panic(err) @@ -104,7 +103,7 @@ func StressTest(_ *cobra.Command, _ []string) { panic(err) } - cctxClient := types.NewQueryClient(grpcConn) + cctxClient := crosschaintypes.NewQueryClient(grpcConn) fungibleClient := fungibletypes.NewQueryClient(grpcConn) bankClient := banktypes.NewQueryClient(grpcConn) authClient := authtypes.NewQueryClient(grpcConn) @@ -114,7 +113,7 @@ func StressTest(_ *cobra.Command, _ []string) { time.Sleep(20 * time.Second) for { time.Sleep(5 * time.Second) - response, err := cctxClient.LastZetaHeight(context.Background(), &types.QueryLastZetaHeightRequest{}) + response, err := cctxClient.LastZetaHeight(context.Background(), &crosschaintypes.QueryLastZetaHeightRequest{}) if err != nil { fmt.Printf("cctxClient.LastZetaHeight error: %s", err) continue @@ -165,9 +164,15 @@ func StressTest(_ *cobra.Command, _ []string) { smokeTest.TestDepositEtherIntoZRC20() smokeTest.TestSendZetaIn() } else if stressTestArgs.network == "TESTNET" { - ethZRC20Addr, _ := smokeTest.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(5)) + ethZRC20Addr, err := smokeTest.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(5)) + if err != nil { + panic(err) + } smokeTest.ETHZRC20Addr = ethZRC20Addr - smokeTest.ETHZRC20, _ = zrc20.NewZRC20(smokeTest.ETHZRC20Addr, smokeTest.zevmClient) + smokeTest.ETHZRC20, err = zrc20.NewZRC20(smokeTest.ETHZRC20Addr, smokeTest.zevmClient) + if err != nil { + panic(err) + } } else { err := errors.New("invalid network argument: " + stressTestArgs.network) panic(err) @@ -192,10 +197,17 @@ func StressTest(_ *cobra.Command, _ []string) { // Get current nonce on zevm for DeployerAddress - Need to keep track of nonce at client level blockNum, err := smokeTest.zevmClient.BlockNumber(context.Background()) + if err != nil { + panic(err) + } + + // #nosec G701 smoketest - always in range nonce, err := smokeTest.zevmClient.NonceAt(context.Background(), DeployerAddress, big.NewInt(int64(blockNum))) if err != nil { panic(err) } + + // #nosec G701 smoketest - always in range zevmNonce = big.NewInt(int64(nonce)) // -------------- TEST BEGINS ------------------ @@ -234,7 +246,7 @@ func (sm *SmokeTest) EchoNetworkMetrics() { case <-ticker.C: numTicks++ // Get all pending outbound transactions - cctxResp, err := sm.cctxClient.CctxAllPending(context.Background(), &types2.QueryAllCctxPendingRequest{ + cctxResp, err := sm.cctxClient.CctxAllPending(context.Background(), &crosschaintypes.QueryAllCctxPendingRequest{ ChainId: getChainID(), }) if err != nil { @@ -251,7 +263,7 @@ func (sm *SmokeTest) EchoNetworkMetrics() { } // // Get all trackers - trackerResp, err := sm.cctxClient.OutTxTrackerAll(context.Background(), &types2.QueryAllOutTxTrackerRequest{}) + trackerResp, err := sm.cctxClient.OutTxTrackerAll(context.Background(), &crosschaintypes.QueryAllOutTxTrackerRequest{}) if err != nil { continue } diff --git a/contrib/localnet/orchestrator/smoketest/test_update_bytecode.go b/contrib/localnet/orchestrator/smoketest/test_update_bytecode.go index f8350b9a12..12f52663be 100644 --- a/contrib/localnet/orchestrator/smoketest/test_update_bytecode.go +++ b/contrib/localnet/orchestrator/smoketest/test_update_bytecode.go @@ -1,9 +1,7 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( + "context" "fmt" "math/big" "time" @@ -36,10 +34,31 @@ func (sm *SmokeTest) TestUpdateBytecode() { // Deploy the TestZRC20 contract fmt.Println("Deploying contract with new bytecode") - newZRC20Address, _, newZRC20Contract, err := testzrc20.DeployTestZRC20(sm.zevmAuth, sm.zevmClient, big.NewInt(5), uint8(common.CoinType_Gas)) + newZRC20Address, tx, newZRC20Contract, err := testzrc20.DeployTestZRC20( + sm.zevmAuth, + sm.zevmClient, + big.NewInt(5), + // #nosec G701 smoketest - always in range + uint8(common.CoinType_Gas), + ) + if err != nil { + panic(err) + } + + // Wait for the contract to be deployed + receipt = MustWaitForTxReceipt(sm.zevmClient, tx) + if receipt.Status != 1 { + panic("contract deployment failed") + } + + // Get the code hash of the new contract + codeHashRes, err := sm.fungibleClient.CodeHash(context.Background(), &fungibletypes.QueryCodeHashRequest{ + Address: newZRC20Address.String(), + }) if err != nil { panic(err) } + fmt.Printf("New contract code hash: %s\n", codeHashRes.CodeHash) // Get current info of the ZRC20 name, err := sm.ETHZRC20.Name(&bind.CallOpts{}) @@ -70,8 +89,8 @@ func (sm *SmokeTest) TestUpdateBytecode() { fmt.Println("Updating the bytecode of the ZRC20") msg := fungibletypes.NewMsgUpdateContractBytecode( FungibleAdminAddress, - sm.ETHZRC20Addr, - newZRC20Address, + sm.ETHZRC20Addr.Hex(), + codeHashRes.CodeHash, ) res, err := sm.zetaTxServer.BroadcastTx(FungibleAdminName, msg) if err != nil { diff --git a/contrib/localnet/orchestrator/smoketest/test_zeta_in_and_out.go b/contrib/localnet/orchestrator/smoketest/test_zeta_in_and_out.go index ced758bad6..211d5531d2 100644 --- a/contrib/localnet/orchestrator/smoketest/test_zeta_in_and_out.go +++ b/contrib/localnet/orchestrator/smoketest/test_zeta_in_and_out.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -62,15 +59,29 @@ func (sm *SmokeTest) TestSendZetaIn() { sm.wg.Add(1) go func() { - bn, _ := sm.zevmClient.BlockNumber(context.Background()) - initialBal, _ := sm.zevmClient.BalanceAt(context.Background(), DeployerAddress, big.NewInt(int64(bn))) + bn, err := sm.zevmClient.BlockNumber(context.Background()) + if err != nil { + panic(err) + } + // #nosec G701 smoketest - always in range + initialBal, err := sm.zevmClient.BalanceAt(context.Background(), DeployerAddress, big.NewInt(int64(bn))) + if err != nil { + panic(err) + } fmt.Printf("Zeta block %d, Initial Deployer Zeta balance: %d\n", bn, initialBal) defer sm.wg.Done() for { time.Sleep(5 * time.Second) - bn, _ = sm.zevmClient.BlockNumber(context.Background()) - bal, _ := sm.zevmClient.BalanceAt(context.Background(), DeployerAddress, big.NewInt(int64(bn))) + bn, err = sm.zevmClient.BlockNumber(context.Background()) + if err != nil { + panic(err) + } + // #nosec G701 smoketest - always in range + bal, err := sm.zevmClient.BalanceAt(context.Background(), DeployerAddress, big.NewInt(int64(bn))) + if err != nil { + panic(err) + } fmt.Printf("Zeta block %d, Deployer Zeta balance: %d\n", bn, bal) diff := big.NewInt(0) diff --git a/contrib/localnet/orchestrator/smoketest/test_zrc20_swap.go b/contrib/localnet/orchestrator/smoketest/test_zrc20_swap.go index 67452cfacf..0a63454915 100644 --- a/contrib/localnet/orchestrator/smoketest/test_zrc20_swap.go +++ b/contrib/localnet/orchestrator/smoketest/test_zrc20_swap.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -25,7 +22,7 @@ func (sm *SmokeTest) TestZRC20Swap() { } receipt := MustWaitForTxReceipt(sm.zevmClient, tx) - fmt.Printf("USDT-ETH pair receipt txhash %s status %d pair addr %s\n", receipt.TxHash, receipt.Status) + fmt.Printf("USDT-ETH pair receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) } usdtEthPair, err := sm.UniswapV2Factory.GetPair(&bind.CallOpts{}, sm.USDTZRC20Addr, sm.ETHZRC20Addr) @@ -48,8 +45,24 @@ func (sm *SmokeTest) TestZRC20Swap() { receipt = MustWaitForTxReceipt(sm.zevmClient, tx) fmt.Printf("ETH ZRC20 approval receipt txhash %s status %d\n", receipt.TxHash, receipt.Status) + // temporarily increase gas limit to 400000 + previousGasLimit := sm.zevmAuth.GasLimit + defer func() { + sm.zevmAuth.GasLimit = previousGasLimit + }() + sm.zevmAuth.GasLimit = 400000 - tx, err = sm.UniswapV2Router.AddLiquidity(sm.zevmAuth, sm.USDTZRC20Addr, sm.ETHZRC20Addr, big.NewInt(90000), big.NewInt(1000), big.NewInt(90000), big.NewInt(1000), DeployerAddress, big.NewInt(time.Now().Add(10*time.Minute).Unix())) + tx, err = sm.UniswapV2Router.AddLiquidity( + sm.zevmAuth, + sm.USDTZRC20Addr, + sm.ETHZRC20Addr, + big.NewInt(90000), + big.NewInt(1000), + big.NewInt(90000), + big.NewInt(1000), + DeployerAddress, + big.NewInt(time.Now().Add(10*time.Minute).Unix()), + ) if err != nil { panic(err) } @@ -61,13 +74,14 @@ func (sm *SmokeTest) TestZRC20Swap() { panic(err) } ethOutAmout := big.NewInt(1) - /*usdtEth, err := contracts.NewUniswapV2Pair(usdtEthPair, sm.zevmClient) - if err != nil { - panic(err) - } - res, err := usdtEth.GetReserves(&bind.CallOpts{}) - fmt.Printf("Reserves %s %s\n", res.Reserve0, res.Reserve1)*/ - tx, err = sm.UniswapV2Router.SwapExactTokensForTokens(sm.zevmAuth, big.NewInt(1000), ethOutAmout, []ethcommon.Address{sm.USDTZRC20Addr, sm.ETHZRC20Addr}, DeployerAddress, big.NewInt(time.Now().Add(10*time.Minute).Unix())) + tx, err = sm.UniswapV2Router.SwapExactTokensForTokens( + sm.zevmAuth, + big.NewInt(1000), + ethOutAmout, + []ethcommon.Address{sm.USDTZRC20Addr, sm.ETHZRC20Addr}, + DeployerAddress, + big.NewInt(time.Now().Add(10*time.Minute).Unix()), + ) if err != nil { panic(err) } diff --git a/contrib/localnet/orchestrator/smoketest/utils.go b/contrib/localnet/orchestrator/smoketest/utils.go index be9dd03f5f..8d0a332488 100644 --- a/contrib/localnet/orchestrator/smoketest/utils.go +++ b/contrib/localnet/orchestrator/smoketest/utils.go @@ -1,6 +1,3 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( @@ -11,59 +8,80 @@ import ( "sync" "time" - rpchttp "github.com/tendermint/tendermint/rpc/client/http" - coretypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/ethereum/go-ethereum/rpc" - "github.com/ethereum/go-ethereum" + "github.com/zeta-chain/zetacore/common" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcutil" + "github.com/ethereum/go-ethereum" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" - "github.com/zeta-chain/zetacore/x/crosschain/types" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" + coretypes "github.com/tendermint/tendermint/rpc/core/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) // WaitCctxMinedByInTxHash waits until cctx is mined; returns the cctxIndex (the last one) -func WaitCctxMinedByInTxHash(inTxHash string, cctxClient types.QueryClient) *types.CrossChainTx { +func WaitCctxMinedByInTxHash(inTxHash string, cctxClient crosschaintypes.QueryClient) *crosschaintypes.CrossChainTx { + cctxs := WaitCctxsMinedByInTxHash(inTxHash, cctxClient, 1) + return cctxs[len(cctxs)-1] +} + +// WaitCctxsMinedByInTxHash waits until cctx is mined; returns the cctxIndex (the last one) +func WaitCctxsMinedByInTxHash(inTxHash string, cctxClient crosschaintypes.QueryClient, cctxsCount int) []*crosschaintypes.CrossChainTx { var cctxIndexes []string for { time.Sleep(5 * time.Second) fmt.Printf("Waiting for cctx to be mined by inTxHash: %s\n", inTxHash) - res, err := cctxClient.InTxHashToCctx(context.Background(), &types.QueryGetInTxHashToCctxRequest{InTxHash: inTxHash}) + res, err := cctxClient.InTxHashToCctx(context.Background(), &crosschaintypes.QueryGetInTxHashToCctxRequest{InTxHash: inTxHash}) if err != nil { fmt.Println("Error getting cctx by inTxHash: ", err.Error()) continue } + if len(res.InTxHashToCctx.CctxIndex) < cctxsCount { + fmt.Printf("Waiting for %d cctxs to be mined; %d cctxs are mined\n", cctxsCount, len(res.InTxHashToCctx.CctxIndex)) + continue + } cctxIndexes = res.InTxHashToCctx.CctxIndex fmt.Printf("Deposit receipt cctx index: %v\n", cctxIndexes) break } var wg sync.WaitGroup - var cctxs []*types.CrossChainTx + var cctxs []*crosschaintypes.CrossChainTx for _, cctxIndex := range cctxIndexes { + cctxIndex := cctxIndex wg.Add(1) go func() { defer wg.Done() for { time.Sleep(3 * time.Second) - res, err := cctxClient.Cctx(context.Background(), &types.QueryGetCctxRequest{Index: cctxIndex}) + res, err := cctxClient.Cctx(context.Background(), &crosschaintypes.QueryGetCctxRequest{Index: cctxIndex}) if err == nil && IsTerminalStatus(res.CrossChainTx.CctxStatus.Status) { fmt.Printf("Deposit receipt cctx status: %+v; The cctx is processed\n", res.CrossChainTx.CctxStatus.Status.String()) cctxs = append(cctxs, res.CrossChainTx) break } else if err != nil { fmt.Println("Error getting cctx by index: ", err.Error()) + } else { + cctxStatus := res.CrossChainTx.CctxStatus + fmt.Printf( + "Deposit receipt cctx status: %s; Message: %s; Waiting for the cctx to be processed\n", + cctxStatus.Status.String(), + cctxStatus.StatusMessage, + ) } } }() } wg.Wait() - return cctxs[len(cctxs)-1] + return cctxs } -func IsTerminalStatus(status types.CctxStatus) bool { - return status == types.CctxStatus_OutboundMined || status == types.CctxStatus_Aborted || status == types.CctxStatus_Reverted +func IsTerminalStatus(status crosschaintypes.CctxStatus) bool { + return status == crosschaintypes.CctxStatus_OutboundMined || status == crosschaintypes.CctxStatus_Aborted || status == crosschaintypes.CctxStatus_Reverted } func LoudPrintf(format string, a ...any) { @@ -105,6 +123,28 @@ func MustWaitForTxReceipt(client *ethclient.Client, tx *ethtypes.Transaction) *e } } +// TraceTx traces the tx and returns the trace result +func TraceTx(tx *ethtypes.Transaction) (string, error) { + rpcClient, err := rpc.Dial(zevmRPC) + if err != nil { + return "", err + } + + var result interface{} + txHash := tx.Hash().Hex() + err = rpcClient.CallContext(context.Background(), &result, "debug_traceTransaction", txHash, map[string]interface{}{ + "disableMemory": true, + "disableStack": false, + "disableStorage": false, + "fullStorage": false, + }) + if err != nil { + return "", err + } + + return fmt.Sprintf("Trace result: %+v\n", result), nil +} + // ScriptPKToAddress is a hex string for P2WPKH script func ScriptPKToAddress(scriptPKHex string) string { pkh, err := hex.DecodeString(scriptPKHex[4:]) @@ -117,6 +157,7 @@ func ScriptPKToAddress(scriptPKHex string) string { return "" } +// WaitForBlockHeight waits until the block height reaches the given height func WaitForBlockHeight(height int64) { // initialize rpc and check status rpc, err := rpchttp.New("http://zetacore0:26657", "/websocket") @@ -125,8 +166,98 @@ func WaitForBlockHeight(height int64) { } status := &coretypes.ResultStatus{} for status.SyncInfo.LatestBlockHeight < height { - status, _ = rpc.Status(context.Background()) + status, err = rpc.Status(context.Background()) + if err != nil { + panic(err) + } time.Sleep(time.Second * 5) fmt.Printf("waiting for block: %d, current height: %d\n", height, status.SyncInfo.LatestBlockHeight) } } + +// DeploySystemContractsAndZRC20 deploys the system contracts and ZRC20 contracts +func DeploySystemContractsAndZRC20(zetaTxServer ZetaTxServer) error { + // Deploy new system contracts + res, err := zetaTxServer.BroadcastTx(FungibleAdminName, fungibletypes.NewMsgDeploySystemContracts(FungibleAdminAddress)) + if err != nil { + return err + } + fmt.Println("System contracts deployed") + + address, err := fetchAttribute(res, "system_contract") + if err != nil { + return err + } + + // set system contract + _, err = zetaTxServer.BroadcastTx(FungibleAdminName, fungibletypes.NewMsgUpdateSystemContract(FungibleAdminAddress, address)) + if err != nil { + return err + } + + // set uniswap contract addresses + UniswapV2FactoryAddr, err = fetchAttribute(res, "uniswap_v2_factory") + if err != nil { + return err + } + UniswapV2RouterAddr, err = fetchAttribute(res, "uniswap_v2_router") + if err != nil { + return err + } + + // deploy eth zrc20 + _, err = zetaTxServer.BroadcastTx(FungibleAdminName, fungibletypes.NewMsgDeployFungibleCoinZRC20( + FungibleAdminAddress, + "", + common.GoerliLocalnetChain().ChainId, + 18, + "ETH", + "gETH", + common.CoinType_Gas, + 1000000, + )) + if err != nil { + return err + } + + // deploy btc zrc20 + _, err = zetaTxServer.BroadcastTx(FungibleAdminName, fungibletypes.NewMsgDeployFungibleCoinZRC20( + FungibleAdminAddress, + "", + common.BtcRegtestChain().ChainId, + 8, + "BTC", + "tBTC", + common.CoinType_Gas, + 1000000, + )) + if err != nil { + return err + } + + // deploy usdt zrc20 + res, err = zetaTxServer.BroadcastTx(FungibleAdminName, fungibletypes.NewMsgDeployFungibleCoinZRC20( + FungibleAdminAddress, + USDTERC20Addr, + common.GoerliLocalnetChain().ChainId, + 6, + "USDT", + "USDT", + common.CoinType_ERC20, + 1000000, + )) + if err != nil { + return err + } + + // fetch the usdt zrc20 contract address and remove the quotes + address, err = fetchAttribute(res, "Contract") + if err != nil { + return err + } + if !ethcommon.IsHexAddress(address) { + return fmt.Errorf("invalid address in event: %s", address) + } + USDTZRC20Addr = address + return nil +} diff --git a/contrib/localnet/orchestrator/smoketest/zeta_tx_server.go b/contrib/localnet/orchestrator/smoketest/zeta_tx_server.go index fac36b10fb..ffe30f3108 100644 --- a/contrib/localnet/orchestrator/smoketest/zeta_tx_server.go +++ b/contrib/localnet/orchestrator/smoketest/zeta_tx_server.go @@ -1,13 +1,12 @@ -//go:build PRIVNET -// +build PRIVNET - package main import ( "context" + "encoding/json" "errors" "fmt" "os" + "strings" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -77,12 +76,6 @@ func NewZetaTxServer(rpcAddr string, names []string, mnemonics []string) (ZetaTx if err != nil { return ZetaTxServer{}, fmt.Errorf("failed to get account address: %s", err.Error()) } - //fmt.Printf( - // "Added account for Zeta tx server\nname: %s\nmnemonic: %s\naddress: %s\n", - // names[i], - // mnemonics[i], - // addr.String(), - //) } clientCtx := newContext(rpc, cdc, reg, kr) @@ -181,10 +174,56 @@ func newFactory(clientCtx client.Context) tx.Factory { return tx.Factory{}. WithChainID(clientCtx.ChainID). WithKeybase(clientCtx.Keyring). - WithGas(300000). - WithGasAdjustment(1.0). + WithGas(10000000). + WithGasAdjustment(1). WithSignMode(signing.SignMode_SIGN_MODE_UNSPECIFIED). WithAccountRetriever(clientCtx.AccountRetriever). WithTxConfig(clientCtx.TxConfig). - WithFees("50azeta") + WithFees("1000azeta") +} + +type messageLog struct { + Events []event `json:"events"` +} + +type event struct { + Type string `json:"type"` + Attributes []attribute `json:"attributes"` +} + +type attribute struct { + Key string `json:"key"` + Value string `json:"value"` +} + +// fetchAttribute fetches the attribute from the tx response +func fetchAttribute(res *sdktypes.TxResponse, key string) (string, error) { + var logs []messageLog + err := json.Unmarshal([]byte(res.RawLog), &logs) + if err != nil { + return "", err + } + + var attributes []string + for _, log := range logs { + for _, event := range log.Events { + for _, attr := range event.Attributes { + attributes = append(attributes, attr.Key) + if strings.EqualFold(attr.Key, key) { + address := attr.Value + + if len(address) < 2 { + return "", fmt.Errorf("invalid address: %s", address) + } + + // trim the quotes + address = address[1 : len(address)-1] + + return address, nil + } + } + } + } + + return "", fmt.Errorf("attribute %s not found, attributes: %+v", key, attributes) } diff --git a/contrib/localnet/zetacored/common/client.toml b/contrib/localnet/zetacored/common/client.toml index bb2e8e1d86..f2b86d8fa5 100644 --- a/contrib/localnet/zetacored/common/client.toml +++ b/contrib/localnet/zetacored/common/client.toml @@ -6,7 +6,7 @@ ############################################################################### # The network chain ID -chain-id = "" +chain-id = "athens_101-1" # The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) keyring-backend = "test" # CLI output format (text|json) diff --git a/contrib/localnet/zetacored/common/config.toml b/contrib/localnet/zetacored/common/config.toml index 0019a7e048..29b433e824 100644 --- a/contrib/localnet/zetacored/common/config.toml +++ b/contrib/localnet/zetacored/common/config.toml @@ -212,7 +212,7 @@ external_address = "" seeds = "" # Comma separated list of nodes to keep persistent connections to -persistent_peers = "0d88fbe57ac13ba86c40f4c82b8a4170e79de21a@172.20.0.12:26656" +persistent_peers = "0d88fbe57ac13ba86c40f4c82b8a4170e79de21a@zetacore1:26656" # UPNP port forwarding upnp = false diff --git a/contrib/localnet/zetacored/zetacored_zetacore0/config/client.toml b/contrib/localnet/zetacored/zetacored_zetacore0/config/client.toml index bb2e8e1d86..f2b86d8fa5 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore0/config/client.toml +++ b/contrib/localnet/zetacored/zetacored_zetacore0/config/client.toml @@ -6,7 +6,7 @@ ############################################################################### # The network chain ID -chain-id = "" +chain-id = "athens_101-1" # The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) keyring-backend = "test" # CLI output format (text|json) diff --git a/contrib/localnet/zetacored/zetacored_zetacore1/config/client.toml b/contrib/localnet/zetacored/zetacored_zetacore1/config/client.toml index bb2e8e1d86..f2b86d8fa5 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore1/config/client.toml +++ b/contrib/localnet/zetacored/zetacored_zetacore1/config/client.toml @@ -6,7 +6,7 @@ ############################################################################### # The network chain ID -chain-id = "" +chain-id = "athens_101-1" # The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) keyring-backend = "test" # CLI output format (text|json) diff --git a/contrib/rpctest/main.go b/contrib/rpctest/main.go index 7d314bc888..202c4bb236 100644 --- a/contrib/rpctest/main.go +++ b/contrib/rpctest/main.go @@ -21,7 +21,7 @@ import ( ) var ( - // #nosec + // #nosec G101 - used for testing only ZetaEthPriv = "9D00E4D7A8A14384E01CD90B83745BCA847A66AD8797A9904A200C28C2648E64" SystemContractAddress = "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921" ) @@ -86,12 +86,10 @@ func main() { if resp.Error != nil { fmt.Printf("Error: %s (code %d)\n", resp.Error.Message, resp.Error.Code) panic(resp.Error.Message) - } else { - //fmt.Printf("Result: %s\n", string(resp.Result)) - err = json.Unmarshal(resp.Result, &jsonObject) - if err != nil { - panic(err) - } + } + err = json.Unmarshal(resp.Result, &jsonObject) + if err != nil { + panic(err) } txs, ok := jsonObject["transactions"].([]interface{}) @@ -154,23 +152,24 @@ func main() { if err != nil { panic(err) } + fmt.Printf("Deploy EthZeta Contract Receipt: %+v\n", receipt) receipt2 := client.EthGetTransactionReceipt(tx2.Hash().Hex()) if receipt2.Error != nil { fmt.Printf("Error: %s (code %d)\n", receipt2.Error.Message, receipt2.Error.Code) panic(tx.Error.Message) - } else { - jsonObject = make(map[string]interface{}) - err = json.Unmarshal(receipt2.Result, &jsonObject) - if err != nil { - panic(err) - } - prettyJSON, err := json.MarshalIndent(jsonObject, "", " ") - if err != nil { - panic(err) - } - fmt.Printf("Result: %s\n", string(prettyJSON)) } + jsonObject = make(map[string]interface{}) + err = json.Unmarshal(receipt2.Result, &jsonObject) + if err != nil { + panic(err) + } + prettyJSON, err := json.MarshalIndent(jsonObject, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("Result: %s\n", string(prettyJSON)) + fmt.Printf("ZetaEth Contract Address: %s\n", zetaContractAddress.Hex()) if zetaContractAddress != receipt.ContractAddress { panic(fmt.Sprintf("Contract address mismatch: wanted %s, got %s", zetaContractAddress, receipt.ContractAddress)) @@ -285,7 +284,8 @@ func (c *EthClient) EthGetBlockByNumber(blockNum uint64, verbose bool) *Response if err != nil { panic(err) } - defer resp.Body.Close() //#nosec + // #nosec G107 - defer close + defer resp.Body.Close() // Decode the response from JSON var rpcResp Response err = json.NewDecoder(resp.Body).Decode(&rpcResp) @@ -326,7 +326,8 @@ func (c *EthClient) EthGetTransactionReceipt(txhash string) *Response { if err != nil { panic(err) } - defer resp.Body.Close() //#nosec + // #nosec G107 - defer close + defer resp.Body.Close() // Decode the response from JSON var rpcResp Response err = json.NewDecoder(resp.Body).Decode(&rpcResp) @@ -367,7 +368,8 @@ func (c *EthClient) EthGetLogs() { //if err != nil { // panic(err) //} - //defer resp.Body.Close() //#nosec + //// #nosec G107 - defer close + //defer resp.Body.Close() //// Decode the response from JSON //var rpcResp Response //err = json.NewDecoder(resp.Body).Decode(&rpcResp) diff --git a/docs/cli/zetacored/zetacored_query_fungible.md b/docs/cli/zetacored/zetacored_query_fungible.md index 284cd10e17..52d7ccc81e 100644 --- a/docs/cli/zetacored/zetacored_query_fungible.md +++ b/docs/cli/zetacored/zetacored_query_fungible.md @@ -25,6 +25,7 @@ zetacored query fungible [flags] ### SEE ALSO * [zetacored query](zetacored_query.md) - Querying subcommands +* [zetacored query fungible code-hash](zetacored_query_fungible_code-hash.md) - shows the code hash of an account * [zetacored query fungible gas-stability-pool-address](zetacored_query_fungible_gas-stability-pool-address.md) - query the address of a gas stability pool * [zetacored query fungible gas-stability-pool-balance](zetacored_query_fungible_gas-stability-pool-balance.md) - query the balance of a gas stability pool for a chain * [zetacored query fungible gas-stability-pool-balances](zetacored_query_fungible_gas-stability-pool-balances.md) - query all gas stability pool balances diff --git a/docs/cli/zetacored/zetacored_query_fungible_code-hash.md b/docs/cli/zetacored/zetacored_query_fungible_code-hash.md new file mode 100644 index 0000000000..8072fa760c --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_fungible_code-hash.md @@ -0,0 +1,33 @@ +# query fungible code-hash + +shows the code hash of an account + +``` +zetacored query fungible code-hash [address] [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for code-hash + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query fungible](zetacored_query_fungible.md) - Querying commands for the fungible module + diff --git a/docs/cli/zetacored/zetacored_query_observer_show-node-account.md b/docs/cli/zetacored/zetacored_query_observer_show-node-account.md index 673a341b36..e597d089e1 100644 --- a/docs/cli/zetacored/zetacored_query_observer_show-node-account.md +++ b/docs/cli/zetacored/zetacored_query_observer_show-node-account.md @@ -3,7 +3,7 @@ shows a NodeAccount ``` -zetacored query observer show-node-account [index] [flags] +zetacored query observer show-node-account [operator_address] [flags] ``` ### Options diff --git a/docs/cli/zetacored/zetacored_tx_crosschain_inbound-voter.md b/docs/cli/zetacored/zetacored_tx_crosschain_inbound-voter.md index 2e419e9158..cfa72e72c6 100644 --- a/docs/cli/zetacored/zetacored_tx_crosschain_inbound-voter.md +++ b/docs/cli/zetacored/zetacored_tx_crosschain_inbound-voter.md @@ -3,7 +3,7 @@ Broadcast message sendVoter ``` -zetacored tx crosschain inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset] [flags] +zetacored tx crosschain inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset] [eventIndex] [flags] ``` ### Options diff --git a/docs/cli/zetacored/zetacored_tx_fungible.md b/docs/cli/zetacored/zetacored_tx_fungible.md index 0ba5834cd3..74f0d5a6a7 100644 --- a/docs/cli/zetacored/zetacored_tx_fungible.md +++ b/docs/cli/zetacored/zetacored_tx_fungible.md @@ -26,6 +26,9 @@ zetacored tx fungible [flags] * [zetacored tx](zetacored_tx.md) - Transactions subcommands * [zetacored tx fungible deploy-fungible-coin-zrc-4](zetacored_tx_fungible_deploy-fungible-coin-zrc-4.md) - Broadcast message DeployFungibleCoinZRC20 +* [zetacored tx fungible deploy-system-contracts](zetacored_tx_fungible_deploy-system-contracts.md) - Broadcast message SystemContracts * [zetacored tx fungible remove-foreign-coin](zetacored_tx_fungible_remove-foreign-coin.md) - Broadcast message RemoveForeignCoin +* [zetacored tx fungible update-contract-bytecode](zetacored_tx_fungible_update-contract-bytecode.md) - Broadcast message UpdateContractBytecode +* [zetacored tx fungible update-system-contract](zetacored_tx_fungible_update-system-contract.md) - Broadcast message UpdateSystemContract * [zetacored tx fungible update-zrc20-liquidity-cap](zetacored_tx_fungible_update-zrc20-liquidity-cap.md) - Broadcast message UpdateZRC20LiquidityCap diff --git a/docs/cli/zetacored/zetacored_tx_fungible_deploy-system-contracts.md b/docs/cli/zetacored/zetacored_tx_fungible_deploy-system-contracts.md new file mode 100644 index 0000000000..c9acde4799 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_fungible_deploy-system-contracts.md @@ -0,0 +1,52 @@ +# tx fungible deploy-system-contracts + +Broadcast message SystemContracts + +``` +zetacored tx fungible deploy-system-contracts [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for deploy-system-contracts + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands + diff --git a/docs/cli/zetacored/zetacored_tx_fungible_update-contract-bytecode.md b/docs/cli/zetacored/zetacored_tx_fungible_update-contract-bytecode.md new file mode 100644 index 0000000000..bc97a583b1 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_fungible_update-contract-bytecode.md @@ -0,0 +1,52 @@ +# tx fungible update-contract-bytecode + +Broadcast message UpdateContractBytecode + +``` +zetacored tx fungible update-contract-bytecode [contract-address] [new-code-hash] [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for update-contract-bytecode + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands + diff --git a/docs/cli/zetacored/zetacored_tx_fungible_update-system-contract.md b/docs/cli/zetacored/zetacored_tx_fungible_update-system-contract.md new file mode 100644 index 0000000000..c9a3e163ec --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_fungible_update-system-contract.md @@ -0,0 +1,52 @@ +# tx fungible update-system-contract + +Broadcast message UpdateSystemContract + +``` +zetacored tx fungible update-system-contract [contract-address] [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for update-system-contract + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands + diff --git a/docs/cli/zetacored/zetacored_tx_observer.md b/docs/cli/zetacored/zetacored_tx_observer.md index a072bed60f..72bcc4c47a 100644 --- a/docs/cli/zetacored/zetacored_tx_observer.md +++ b/docs/cli/zetacored/zetacored_tx_observer.md @@ -31,4 +31,5 @@ zetacored tx observer [flags] * [zetacored tx observer update-client-params](zetacored_tx_observer_update-client-params.md) - Broadcast message updateClientParams * [zetacored tx observer update-crosschain-flags](zetacored_tx_observer_update-crosschain-flags.md) - Update crosschain flags * [zetacored tx observer update-keygen](zetacored_tx_observer_update-keygen.md) - command to update the keygen block via a group proposal +* [zetacored tx observer update-observer](zetacored_tx_observer_update-observer.md) - Broadcast message add-observer diff --git a/docs/cli/zetacored/zetacored_tx_observer_update-observer.md b/docs/cli/zetacored/zetacored_tx_observer_update-observer.md new file mode 100644 index 0000000000..bee8851349 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_observer_update-observer.md @@ -0,0 +1,52 @@ +# tx observer update-observer + +Broadcast message add-observer + +``` +zetacored tx observer update-observer [old-observer-address] [new-observer-address] [update-reason] [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for update-observer + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx observer](zetacored_tx_observer.md) - observer transactions subcommands + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index a80b3f72e1..f1ec700e20 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -26646,6 +26646,32 @@ paths: type: boolean tags: - Query + /zeta-chain/crosschain/cctxbyStatus/{status}: + get: + operationId: Query_CctxByStatus + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/crosschainQueryCctxByStatusResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: status + in: path + required: true + type: string + enum: + - PendingInbound + - PendingOutbound + - OutboundMined + - PendingRevert + - Reverted + - Aborted + tags: + - Query /zeta-chain/crosschain/chainNonces: get: summary: Queries a list of chainNonces items. @@ -26846,6 +26872,11 @@ paths: in: query required: false type: string + - name: bitcoin_chain_id + in: query + required: false + type: string + format: int64 tags: - Query /zeta-chain/crosschain/in_tx_hash_to_cctx_data/{inTxHash}: @@ -27408,6 +27439,26 @@ paths: type: string tags: - Query + /zeta-chain/fungible/code_hash/{address}: + get: + summary: Code hash query the code hash of a contract. + operationId: Query_CodeHash + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/fungibleQueryCodeHashResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: address + in: path + required: true + type: string + tags: + - Query /zeta-chain/fungible/foreign_coins: get: summary: Queries a list of ForeignCoins items. @@ -50834,6 +50885,14 @@ definitions: items: type: object $ref: '#/definitions/crosschainPendingNonces' + crosschainQueryCctxByStatusResponse: + type: object + properties: + CrossChainTx: + type: array + items: + type: object + $ref: '#/definitions/crosschainCrossChainTx' crosschainQueryConvertGasToZetaResponse: type: object properties: @@ -51015,14 +51074,23 @@ definitions: properties: address: type: string + fungibleMsgDeploySystemContractsResponse: + type: object + properties: + uniswapV2Factory: + type: string + wzeta: + type: string + uniswapV2Router: + type: string + connectorZEVM: + type: string + systemContract: + type: string fungibleMsgRemoveForeignCoinResponse: type: object fungibleMsgUpdateContractBytecodeResponse: type: object - properties: - new_bytecode_hash: - type: string - format: byte fungibleMsgUpdateSystemContractResponse: type: object fungibleMsgUpdateZRC20LiquidityCapResponse: @@ -51049,6 +51117,11 @@ definitions: items: type: object $ref: '#/definitions/QueryAllGasStabilityPoolBalanceResponseBalance' + fungibleQueryCodeHashResponse: + type: object + properties: + code_hash: + type: string fungibleQueryGetForeignCoinsResponse: type: object properties: @@ -51256,6 +51329,8 @@ definitions: type: object observerMsgUpdateKeygenResponse: type: object + observerMsgUpdateObserverResponse: + type: object observerNode: type: object properties: @@ -51319,6 +51394,13 @@ definitions: type: string is_supported: type: boolean + observerObserverUpdateReason: + type: string + enum: + - Undefined + - Tombstoned + - AdminUpdate + default: Undefined observerPolicy_Type: type: string enum: diff --git a/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index f167df5c94..6c65cf8098 100644 --- a/docs/spec/crosschain/messages.md +++ b/docs/spec/crosschain/messages.md @@ -219,6 +219,7 @@ message MsgVoteOnObservedInboundTx { common.CoinType coin_type = 12; string tx_origin = 13; string asset = 14; + uint64 event_index = 15; } ``` diff --git a/docs/spec/fungible/messages.md b/docs/spec/fungible/messages.md index 984455ff41..7e77e642df 100644 --- a/docs/spec/fungible/messages.md +++ b/docs/spec/fungible/messages.md @@ -1,5 +1,15 @@ # Messages +## MsgDeploySystemContracts + +DeploySystemContracts deploy new instances of the system contracts + +```proto +message MsgDeploySystemContracts { + string creator = 1; +} +``` + ## MsgDeployFungibleCoinZRC20 DeployFungibleCoinZRC20 deploys a fungible coin from a connected chains as a ZRC20 on ZetaChain. @@ -67,7 +77,7 @@ the new contract can add new variable but cannot remove any existing variable message MsgUpdateContractBytecode { string creator = 1; string contract_address = 2; - string new_bytecode_address = 3; + string new_code_hash = 3; } ``` diff --git a/docs/spec/observer/messages.md b/docs/spec/observer/messages.md index 3f7f4cc5d9..84b9e4dbd4 100644 --- a/docs/spec/observer/messages.md +++ b/docs/spec/observer/messages.md @@ -2,9 +2,6 @@ ## MsgAddObserver -AddObserver adds in a new observer to the store.It can be executed using an admin policy account -Once added, the function also resets keygen and pauses inbound so that a new TSS can be generated. - ```proto message MsgAddObserver { string creator = 1; @@ -14,6 +11,17 @@ message MsgAddObserver { } ``` +## MsgUpdateObserver + +```proto +message MsgUpdateObserver { + string creator = 1; + string old_observer_address = 2; + string new_observer_address = 3; + ObserverUpdateReason update_reason = 4; +} +``` + ## MsgUpdateCoreParams UpdateCoreParams updates core parameters for a specific chain. Core parameters include diff --git a/go.mod b/go.mod index 2c5e8c79f1..30b1abe989 100644 --- a/go.mod +++ b/go.mod @@ -37,10 +37,12 @@ require ( github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/emicklei/proto v1.11.1 github.com/evmos/ethermint v0.22.0 + github.com/frumioj/crypto11 v1.2.5-0.20210823151709-946ce662cc0e github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/zeta-chain/go-tss v0.1.0 + github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b github.com/zeta-chain/tss-lib v0.1.7 google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc @@ -82,6 +84,7 @@ require ( github.com/jmhodges/levigo v1.0.0 // indirect github.com/libp2p/go-yamux/v4 v4.0.0 // indirect github.com/linxGnu/grocksdb v1.7.15 // indirect + github.com/miekg/pkcs11 v1.1.1 // indirect github.com/onsi/ginkgo/v2 v2.9.7 // indirect github.com/prometheus/tsdb v0.7.1 // indirect github.com/quic-go/qpack v0.4.0 // indirect @@ -92,6 +95,7 @@ require ( github.com/rjeczalik/notify v0.9.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect + github.com/thales-e-security/pool v0.0.2 // indirect github.com/tidwall/gjson v1.14.4 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect diff --git a/go.sum b/go.sum index 78d4bd4639..77802118ff 100644 --- a/go.sum +++ b/go.sum @@ -431,6 +431,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= +filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= @@ -439,6 +440,7 @@ git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFN git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= +github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/Abirdcfly/dupword v0.0.7/go.mod h1:K/4M1kj+Zh39d2aotRwypvasonOyAMH1c/IZJzE0dmk= @@ -464,6 +466,7 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2 github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/azure-service-bus-go v0.9.1/go.mod h1:yzBx6/BUGfjfeqbRZny9AQIbIe3AcV9WZbAdpkoXOa0= +github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= github.com/Azure/azure-storage-blob-go v0.8.0/go.mod h1:lPI3aLPpuLTeUwh1sViKXFxwl2B6teiRqI0deQUvsw0= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= @@ -523,6 +526,7 @@ github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMd github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= @@ -596,6 +600,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= @@ -639,6 +644,7 @@ github.com/apex/log v1.3.0/go.mod h1:jd8Vpsr46WAe3EZSQ/IUMs2qQD/GOycT5rPWCO1yGcs github.com/apex/logs v0.0.4/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo= github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE= github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= +github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= @@ -665,6 +671,7 @@ github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= @@ -708,6 +715,7 @@ github.com/binance-chain/ledger-cosmos-go v0.9.9-binance.1/go.mod h1:FI6WAujuiBp github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI= github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= @@ -825,6 +833,7 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/cloudflare/circl v1.3.1/go.mod h1:+CauBF6R70Jqcyl8N2hC8pAXYbWkGIezuSbuGLtRhnw= +github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -856,6 +865,7 @@ github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9D github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v0.0.0-20220726134658-7b78c71e4055/go.mod h1:890yq1fUb9b6dGNwssgeUO5vQV9qfXnCPxAJhBQfXw0= +github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677/go.mod h1:890yq1fUb9b6dGNwssgeUO5vQV9qfXnCPxAJhBQfXw0= github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= @@ -866,6 +876,7 @@ github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= +github.com/coinbase/rosetta-sdk-go v0.6.10/go.mod h1:J/JFMsfcePrjJZkwQFLh+hJErkAmdm9Iyy3D5Y0LfXo= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= github.com/cometbft/cometbft v0.34.28 h1:gwryf55P1SWMUP4nOXpRVI2D0yPoYEzN+IBqmRBOsDc= @@ -1019,6 +1030,7 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk v0.43.0/go.mod h1:ctcrTEAhei9s8O3KSNvL0dxe+fVQGp07QyRb/7H9JYE= github.com/cosmos/cosmos-sdk v0.46.13 h1:LhL6WDBadczqBuCW0t5BHUzGQR3vbujdOYOfU0ORt+o= github.com/cosmos/cosmos-sdk v0.46.13/go.mod h1:EfY521ATNEla8eJ6oJuZBdgP5+p360s7InnRqX+TWdM= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= @@ -1028,12 +1040,15 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogoproto v1.4.7 h1:RzYKVnsEC7UIkDnhTIkqEB7LnIQbsySvmNEqPCiPevk= github.com/cosmos/gogoproto v1.4.7/go.mod h1:gxGePp9qedovvl/StQL2BIJ6qlIBn1+9YxR0IulGBKA= +github.com/cosmos/iavl v0.16.0/go.mod h1:2A8O/Jz9YwtjqXMO0CjnnbTYEEaovE8jWcwrakH3PoE= github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU= github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go/v6 v6.1.0 h1:o7oXws2vKkKfOFzJI+oNylRn44PCNt5wzHd/zKQKbvQ= github.com/cosmos/ibc-go/v6 v6.1.0/go.mod h1:CY3zh2HLfetRiW8LY6kVHMATe90Wj/UOoY8T6cuB0is= +github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -1055,6 +1070,7 @@ github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8= github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I= github.com/daixiang0/gci v0.8.1/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c= +github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7hqDjlFjiygg= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= @@ -1067,6 +1083,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= +github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= @@ -1086,6 +1103,7 @@ github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -1101,6 +1119,7 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= +github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -1145,6 +1164,7 @@ github.com/docker/libnetwork v0.8.0-dev.2.0.20200917202933-d0951081b35f/go.mod h github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 h1:kgvzE5wLsLa7XKfV85VZl40QXaMCaeFtHpPwJ8fhotY= @@ -1154,12 +1174,15 @@ github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8 github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= +github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= @@ -1173,6 +1196,7 @@ github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT github.com/emicklei/proto v1.11.1 h1:CBZwNVwPJvkdevxvsoCuFedF9ENiBz0saen3L9y0OTA= github.com/emicklei/proto v1.11.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25/go.mod h1:hTr8+TLQmkUkgcuh3mcr5fjrT9c64ZzsBCdCEC6UppY= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -1192,6 +1216,7 @@ github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= @@ -1209,6 +1234,7 @@ github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqL github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= +github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= @@ -1221,6 +1247,7 @@ github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= +github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= @@ -1241,6 +1268,8 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frumioj/crypto11 v1.2.5-0.20210823151709-946ce662cc0e h1:HRagc2sBsKLDvVVXQMaCEU8ueRFAl3txucwykhQPbGc= +github.com/frumioj/crypto11 v1.2.5-0.20210823151709-946ce662cc0e/go.mod h1:/1u7qgWwAI7wja4BdNu5Vd5gqMtmtoiACHlhl46uY1E= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= @@ -1344,6 +1373,7 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -1464,6 +1494,8 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -1627,6 +1659,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= @@ -1645,6 +1678,7 @@ github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/gotestyourself/gotestyourself v1.4.0/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -1751,11 +1785,13 @@ github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKEN github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/uuid v0.0.0-20160311170451-ebb0a03e909c/go.mod h1:fHzc09UnyJyqyW+bFuq864eh+wC7dj65aXmXLRe5to0= +github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87/go.mod h1:XGsKKeXxeRr95aEOgipvluMPlgjr7dGlk9ZTWOjcUcg= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.2.2 h1:TXKcSGc2WaxPD2+bmzAsVthL4+pEN0YwXcL5qED83vk= github.com/holiman/uint256 v1.2.2/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= @@ -1783,6 +1819,7 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= +github.com/improbable-eng/grpc-web v0.14.0/go.mod h1:6hRR09jOEG81ADP5wCQju1z71g6OL4eEvELdran/3cs= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -1790,6 +1827,7 @@ github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= +github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= @@ -1830,6 +1868,7 @@ github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrO github.com/ishidawataru/sctp v0.0.0-20191218070446-00ab2ac2db07/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw= +github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea/go.mod h1:QMdK4dGB3YhEW2BmA1wgGpPYI3HZy/5gD705PXKUVSg= @@ -1850,6 +1889,7 @@ github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSl github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= +github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= github.com/jhump/protoreflect v1.13.1-0.20220928232736-101791cb1b4c/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= @@ -1903,12 +1943,14 @@ github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0b github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= +github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= +github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= @@ -1920,11 +1962,13 @@ github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiD github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.3/go.mod h1:PG/cwd6c0705/LM0KTr1acO2gORUxkSVWyLJOFW5qoo= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= @@ -1939,6 +1983,7 @@ github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8 github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= @@ -2069,6 +2114,7 @@ github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlW github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -2085,6 +2131,7 @@ github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HN github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -2092,6 +2139,7 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= @@ -2137,7 +2185,9 @@ github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0 github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= @@ -2174,6 +2224,7 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -2288,11 +2339,13 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= +github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= github.com/networkplumbing/go-nft v0.2.0/go.mod h1:HnnM+tYvlGAsMU7yoYwXEVLLiDW9gdMmb5HoGcwpuQs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.8.3/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg= github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= github.com/notional-labs/cometbft-db v0.0.0-20230321185329-6dc7c0ca6345 h1:QeXhTzmndyedxsINoIZLWkDF17U9V/yCaBffFYXjbaQ= github.com/notional-labs/cometbft-db v0.0.0-20230321185329-6dc7c0ca6345/go.mod h1:a5TUP6VLnFBEcmg+xhGwb2lO9BjzkHGxg0c8wyRfjN8= @@ -2305,6 +2358,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -2404,12 +2458,14 @@ github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4 github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/copy v1.6.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.2.4/go.mod h1:d+b7n/0R3tdyUYYylALXpWQ/kTN+QobSq/4SRGBkR3M= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= +github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/otiai10/primes v0.0.0-20180210170552-f6d2a1ba97c4 h1:blMAhTXF6uL1+e3eVSajjLT43Cc0U8mU1gcigbbolJM= github.com/otiai10/primes v0.0.0-20180210170552-f6d2a1ba97c4/go.mod h1:UmSP7QeU3XmAdGu5+dnrTJqjBc+IscpVZkQzk473cjM= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= @@ -2420,6 +2476,7 @@ github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChl github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= +github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= @@ -2509,6 +2566,7 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= @@ -2532,6 +2590,7 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= @@ -2566,6 +2625,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= +github.com/regen-network/keystone/keys v0.0.0-20220129212613-fb67e4f8db9f h1:mZzWwq+8mlPD26RKF0dFZf6zqT3rIlMUiG6XAj9S8DU= +github.com/regen-network/keystone/keys v0.0.0-20220129212613-fb67e4f8db9f/go.mod h1:kElF/8eluneHAO2s1UnFl0Jy5An3f7OiXbzUI+1vnJU= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= @@ -2584,13 +2645,16 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= @@ -2638,6 +2702,7 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc= +github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.22.9/go.mod h1:bBYl1kjgEJpWpxeHmLI+dVHWtyAwfcmSBLDsp2TNT8A= @@ -2739,6 +2804,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/spf13/viper v1.8.0/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw= @@ -2749,6 +2815,8 @@ github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZL github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= +github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= +github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -2813,17 +2881,23 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1: github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= github.com/tetafro/godot v0.4.2/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0= github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= +github.com/thales-e-security/pool v0.0.2 h1:RAPs4q2EbWsTit6tpzuvTFlgFRJ3S8Evf5gtvVDbmPg= +github.com/thales-e-security/pool v0.0.2/go.mod h1:qtpMm2+thHtqhLzTwgDBj/OuNnMpupY8mv0Phz0gjhU= github.com/tidwall/btree v1.5.0 h1:iV0yVY/frd7r6qGBXfEYs7DH0gTDgrKTrDjS7xt/IyQ= github.com/tidwall/btree v1.5.0/go.mod h1:LGm8L/DZjPLmeWGjv5kFrY8dL4uVhMmzmmLYmsObdKE= +github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg= github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= @@ -2917,7 +2991,9 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= @@ -2928,6 +3004,7 @@ github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1 github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= +github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/xanzy/go-gitlab v0.31.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= github.com/xanzy/go-gitlab v0.32.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= @@ -2963,6 +3040,8 @@ github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPS github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= github.com/zeta-chain/go-tss v0.1.0 h1:3sqSQGOW42j516xihIXDx+YjAYMWbCryEt14cufHb+g= github.com/zeta-chain/go-tss v0.1.0/go.mod h1:pXgFOVodqkNxbjLe6N0Lx8FFjNTDST3C9H8J1/8LNXk= +github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM= +github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b h1:aZRt5BtXdoDdyrUKwcv3B7mS30m/B854cjKjmnXBE5A= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= github.com/zeta-chain/tss-lib v0.1.7 h1:NkIaK7qIeb2B8z85PW0wnAaEP87ZUvgA/V3el7Kf5Tk= @@ -3136,6 +3215,7 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -3171,6 +3251,7 @@ golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= @@ -3206,10 +3287,12 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -3277,6 +3360,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -3317,6 +3401,7 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= @@ -3346,6 +3431,7 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -3470,6 +3556,7 @@ golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -3557,6 +3644,7 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -3675,6 +3763,7 @@ golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200102140908-9497f49d5709/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200108203644-89082a384178/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -3699,6 +3788,7 @@ golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -3708,6 +3798,7 @@ golang.org/x/tools v0.0.0-20200625211823-6506e20df31f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -3806,6 +3897,7 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= @@ -3908,6 +4000,7 @@ google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -4069,6 +4162,7 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= @@ -4101,6 +4195,7 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/proto/crosschain/query.proto b/proto/crosschain/query.proto index e05265258d..2f38d17cbb 100644 --- a/proto/crosschain/query.proto +++ b/proto/crosschain/query.proto @@ -143,6 +143,17 @@ service Query { rpc TssHistory(QueryTssHistoryRequest) returns (QueryTssHistoryResponse) { option (google.api.http).get = "/zeta-chain/crosschain/tssHistory"; } + + rpc CctxByStatus(QueryCctxByStatusRequest) returns (QueryCctxByStatusResponse) { + option (google.api.http).get = "/zeta-chain/crosschain/cctxbyStatus/{status}"; + } +} + +message QueryCctxByStatusRequest { + CctxStatus status = 1; +} +message QueryCctxByStatusResponse { + repeated CrossChainTx CrossChainTx = 1 [(gogoproto.nullable) = false]; } message QueryTssHistoryRequest {} @@ -231,6 +242,7 @@ message QueryAllInTxHashToCctxResponse { message QueryGetTssAddressRequest { string tss_pub_key = 1; + int64 bitcoin_chain_id = 2; } message QueryGetTssAddressResponse { diff --git a/proto/crosschain/tx.proto b/proto/crosschain/tx.proto index eabdbf19e1..657caa7f55 100644 --- a/proto/crosschain/tx.proto +++ b/proto/crosschain/tx.proto @@ -157,6 +157,8 @@ message MsgVoteOnObservedInboundTx { common.CoinType coin_type = 12; string tx_origin = 13; string asset = 14; + // event index of the sent asset in the observed tx + uint64 event_index = 15; } message MsgVoteOnObservedInboundTxResponse {} diff --git a/proto/fungible/events.proto b/proto/fungible/events.proto index 4c66f1a940..06e7af005f 100644 --- a/proto/fungible/events.proto +++ b/proto/fungible/events.proto @@ -44,3 +44,21 @@ message EventZRC20PausedStatusUpdated { UpdatePausedStatusAction action = 3; string signer = 4; } + +message EventSystemContractsDeployed { + string msg_type_url = 1; + string uniswap_v2_factory = 2; + string wzeta = 3; + string uniswap_v2_router = 4; + string connector_zevm = 5; + string system_contract = 6; + string signer = 7; +} + +message EventBytecodeUpdated { + string msg_type_url = 1; + string contract_address = 2; + string new_bytecode_hash = 3; + string old_bytecode_hash = 4; + string signer = 5; +} diff --git a/proto/fungible/query.proto b/proto/fungible/query.proto index 50e573ea32..94e4165cdd 100644 --- a/proto/fungible/query.proto +++ b/proto/fungible/query.proto @@ -16,6 +16,7 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/zeta-chain/fungible/params"; } + // Queries a ForeignCoins by index. rpc ForeignCoins(QueryGetForeignCoinsRequest) returns (QueryGetForeignCoinsResponse) { option (google.api.http).get = "/zeta-chain/fungible/foreign_coins/{index}"; @@ -45,6 +46,11 @@ service Query { rpc GasStabilityPoolBalanceAll(QueryAllGasStabilityPoolBalance) returns (QueryAllGasStabilityPoolBalanceResponse) { option (google.api.http).get = "/zeta-chain/zetacore/fungible/gas_stability_pool_balance"; } + + // Code hash query the code hash of a contract. + rpc CodeHash(QueryCodeHashRequest) returns (QueryCodeHashResponse) { + option (google.api.http).get = "/zeta-chain/fungible/code_hash/{address}"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -103,3 +109,11 @@ message QueryAllGasStabilityPoolBalanceResponse { } repeated Balance balances = 1 [(gogoproto.nullable) = false]; } + +message QueryCodeHashRequest { + string address = 1; +} + +message QueryCodeHashResponse { + string code_hash = 1; +} diff --git a/proto/fungible/tx.proto b/proto/fungible/tx.proto index 34608edb22..e6599a55b9 100644 --- a/proto/fungible/tx.proto +++ b/proto/fungible/tx.proto @@ -8,6 +8,7 @@ option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; // Msg defines the Msg service. service Msg { + rpc DeploySystemContracts(MsgDeploySystemContracts) returns (MsgDeploySystemContractsResponse); rpc DeployFungibleCoinZRC20(MsgDeployFungibleCoinZRC20) returns (MsgDeployFungibleCoinZRC20Response); rpc RemoveForeignCoin(MsgRemoveForeignCoin) returns (MsgRemoveForeignCoinResponse); rpc UpdateSystemContract(MsgUpdateSystemContract) returns (MsgUpdateSystemContractResponse); @@ -17,6 +18,18 @@ service Msg { rpc UpdateZRC20LiquidityCap(MsgUpdateZRC20LiquidityCap) returns (MsgUpdateZRC20LiquidityCapResponse); } +message MsgDeploySystemContracts { + string creator = 1; +} + +message MsgDeploySystemContractsResponse { + string uniswapV2Factory = 1; + string wzeta = 2; + string uniswapV2Router = 3; + string connectorZEVM = 4; + string systemContract = 5; +} + message MsgUpdateZRC20WithdrawFee { string creator = 1; string zrc20_address = 2; // zrc20 address @@ -64,12 +77,10 @@ message MsgRemoveForeignCoinResponse {} message MsgUpdateContractBytecode { string creator = 1; string contract_address = 2; - string new_bytecode_address = 3; + string new_code_hash = 3; } -message MsgUpdateContractBytecodeResponse { - bytes new_bytecode_hash = 1; -} +message MsgUpdateContractBytecodeResponse {} enum UpdatePausedStatusAction { PAUSE = 0; diff --git a/proto/observer/observer.proto b/proto/observer/observer.proto index 2ad3ffb3bf..32be146492 100644 --- a/proto/observer/observer.proto +++ b/proto/observer/observer.proto @@ -15,6 +15,13 @@ enum ObservationType { TSSKeySign = 4; } +enum ObserverUpdateReason { + option (gogoproto.goproto_enum_stringer) = true; + Undefined = 0; + Tombstoned = 1; + AdminUpdate = 2; +} + message ObserverMapper { string index = 1; common.Chain observer_chain = 2; diff --git a/proto/observer/tx.proto b/proto/observer/tx.proto index 7d1fd5e1e2..8c8d227a9c 100644 --- a/proto/observer/tx.proto +++ b/proto/observer/tx.proto @@ -13,6 +13,7 @@ option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; // Msg defines the Msg service. service Msg { rpc AddObserver(MsgAddObserver) returns (MsgAddObserverResponse); + rpc UpdateObserver(MsgUpdateObserver) returns (MsgUpdateObserverResponse); rpc UpdateCoreParams(MsgUpdateCoreParams) returns (MsgUpdateCoreParamsResponse); rpc AddBlameVote(MsgAddBlameVote) returns (MsgAddBlameVoteResponse); rpc UpdateCrosschainFlags(MsgUpdateCrosschainFlags) returns (MsgUpdateCrosschainFlagsResponse); @@ -20,6 +21,14 @@ service Msg { rpc AddBlockHeader(MsgAddBlockHeader) returns (MsgAddBlockHeaderResponse); } +message MsgUpdateObserver { + string creator = 1; + string old_observer_address = 2; + string new_observer_address = 3; + ObserverUpdateReason update_reason = 4; +} +message MsgUpdateObserverResponse {} + message MsgAddBlockHeader { string creator = 1; int64 chain_id = 2; diff --git a/readme.md b/readme.md index b9db6be3c2..9647685d66 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,18 @@ +# ⚠️ Important Notice: Code Freeze for Security Audit ⚠️ + +Dear Contributors and Users, +We are committed to ensuring the highest standards of security and reliability in our project. To uphold this commitment, we are currently undergoing a thorough security audit conducted by Code4rena. More info: https://code4rena.com/contests/2023-11-zetachain. + +During this period, we have instituted a code freeze on our public repository. This means there will be no new commits, merges, or major changes to the codebase until the audit is complete. This process is crucial to maintain the integrity and consistency of the code being audited. + +The audit is scheduled from 20 Nov 9:00 PM GMT+1 to 18 Dec 9:00 PM GMT+1. We appreciate your patience and understanding during this vital phase of our project's development. + +During this time, we encourage our community to review the current codebase and documentation. While we won't be merging new changes, we welcome your feedback, which we will address post-audit. + +For any questions or concerns, feel free to reach out to us on our [Discord](https://discord.com/invite/zetachain). + +Thank you for your cooperation and support! + # ZetaChain ZetaChain is an EVM-compatible L1 blockchain that enables omnichain, generic diff --git a/rpc/namespaces/ethereum/debug/api.go b/rpc/namespaces/ethereum/debug/api.go index 94f771ab39..2861e2b12a 100644 --- a/rpc/namespaces/ethereum/debug/api.go +++ b/rpc/namespaces/ethereum/debug/api.go @@ -200,7 +200,7 @@ func (a *API) StartCPUProfile(file string) error { a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error()) return err } - /* #nosec */ + // #nosec G304 variable value is controlled f, err := os.Create(fp) if err != nil { a.logger.Debug("failed to create CPU profile file", "error", err.Error()) diff --git a/rpc/namespaces/ethereum/debug/trace.go b/rpc/namespaces/ethereum/debug/trace.go index 3f45795227..28ba1c8043 100644 --- a/rpc/namespaces/ethereum/debug/trace.go +++ b/rpc/namespaces/ethereum/debug/trace.go @@ -42,7 +42,7 @@ func (a *API) StartGoTrace(file string) error { a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error()) return err } - /* #nosec */ + // #nosec G304 variable value is controlled f, err := os.Create(fp) if err != nil { a.logger.Debug("failed to create go trace file", "error", err.Error()) diff --git a/rpc/namespaces/ethereum/debug/utils.go b/rpc/namespaces/ethereum/debug/utils.go index 57a2e0f113..a65134977d 100644 --- a/rpc/namespaces/ethereum/debug/utils.go +++ b/rpc/namespaces/ethereum/debug/utils.go @@ -59,7 +59,7 @@ func writeProfile(name, file string, log log.Logger) error { if err != nil { return err } - /* #nosec */ + // #nosec G304 variable value is controlled f, err := os.Create(fp) if err != nil { return err diff --git a/rpc/websockets.go b/rpc/websockets.go index 84d334e952..b81e49748e 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -354,7 +354,6 @@ func (s *websocketsServer) tcpGetAndSendResponse(wsConn *wsConn, mb []byte) erro return errors.Wrap(err, "Could not perform request") } - /* #nosec */ defer resp.Body.Close() body, err := io.ReadAll(resp.Body) diff --git a/server/start.go b/server/start.go index e490886733..3863144995 100644 --- a/server/start.go +++ b/server/start.go @@ -305,7 +305,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt ctx.Logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error()) return err } - /* #nosec */ + // #nosec G304 - users can't control the filepath f, err := os.Create(fp) if err != nil { return err diff --git a/testutil/contracts/Depositor.abi b/testutil/contracts/Depositor.abi new file mode 100644 index 0000000000..63cc3e693f --- /dev/null +++ b/testutil/contracts/Depositor.abi @@ -0,0 +1,46 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "custody_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "recipient", + "type": "bytes" + }, + { + "internalType": "contract IERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "runDeposits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/testutil/contracts/Depositor.bin b/testutil/contracts/Depositor.bin new file mode 100644 index 0000000000..6a04cda63a --- /dev/null +++ b/testutil/contracts/Depositor.bin @@ -0,0 +1 @@ +60a060405234801561001057600080fd5b5060405161078a38038061078a833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161066d61011d6000396000818160e4015261016b015261066d6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a60048036038101906100459190610330565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd33308488610076919061041b565b6040518463ffffffff1660e01b81526004016100949392919061047b565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f919061041b565b6040518363ffffffff1660e01b815260040161012c9291906104b2565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b81811015610211577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610598565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080610209906105ef565b915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261024a57610249610225565b5b8235905067ffffffffffffffff8111156102675761026661022a565b5b6020830191508360018202830111156102835761028261022f565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102b58261028a565b9050919050565b60006102c7826102aa565b9050919050565b6102d7816102bc565b81146102e257600080fd5b50565b6000813590506102f4816102ce565b92915050565b6000819050919050565b61030d816102fa565b811461031857600080fd5b50565b60008135905061032a81610304565b92915050565b600080600080600080600060a0888a03121561034f5761034e61021b565b5b600088013567ffffffffffffffff81111561036d5761036c610220565b5b6103798a828b01610234565b9750975050602061038c8a828b016102e5565b955050604061039d8a828b0161031b565b945050606088013567ffffffffffffffff8111156103be576103bd610220565b5b6103ca8a828b01610234565b935093505060806103dd8a828b0161031b565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610426826102fa565b9150610431836102fa565b925082820261043f816102fa565b91508282048414831517610456576104556103ec565b5b5092915050565b610466816102aa565b82525050565b610475816102fa565b82525050565b6000606082019050610490600083018661045d565b61049d602083018561045d565b6104aa604083018461046c565b949350505050565b60006040820190506104c7600083018561045d565b6104d4602083018461046c565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051883856104db565b93506105258385846104ec565b61052e836104fb565b840190509392505050565b6000819050919050565b600061055e6105596105548461028a565b610539565b61028a565b9050919050565b600061057082610543565b9050919050565b600061058282610565565b9050919050565b61059281610577565b82525050565b600060808201905081810360008301526105b381888a61050c565b90506105c26020830187610589565b6105cf604083018661046c565b81810360608301526105e281848661050c565b9050979650505050505050565b60006105fa826102fa565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361062c5761062b6103ec565b5b60018201905091905056fea264697066735822122052c5caf083af6e05e3cd0c0e628630fe7cba46565021425413eabeb4a56b4b5464736f6c63430008150033 diff --git a/testutil/contracts/Depositor.go b/testutil/contracts/Depositor.go new file mode 100644 index 0000000000..2fa459f0d7 --- /dev/null +++ b/testutil/contracts/Depositor.go @@ -0,0 +1,224 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +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 + _ = abi.ConvertType +) + +// DepositorMetaData contains all meta data concerning the Depositor contract. +var DepositorMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"custody_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runDeposits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561001057600080fd5b5060405161078a38038061078a833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161066d61011d6000396000818160e4015261016b015261066d6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a60048036038101906100459190610330565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd33308488610076919061041b565b6040518463ffffffff1660e01b81526004016100949392919061047b565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f919061041b565b6040518363ffffffff1660e01b815260040161012c9291906104b2565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b81811015610211577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610598565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080610209906105ef565b915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261024a57610249610225565b5b8235905067ffffffffffffffff8111156102675761026661022a565b5b6020830191508360018202830111156102835761028261022f565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102b58261028a565b9050919050565b60006102c7826102aa565b9050919050565b6102d7816102bc565b81146102e257600080fd5b50565b6000813590506102f4816102ce565b92915050565b6000819050919050565b61030d816102fa565b811461031857600080fd5b50565b60008135905061032a81610304565b92915050565b600080600080600080600060a0888a03121561034f5761034e61021b565b5b600088013567ffffffffffffffff81111561036d5761036c610220565b5b6103798a828b01610234565b9750975050602061038c8a828b016102e5565b955050604061039d8a828b0161031b565b945050606088013567ffffffffffffffff8111156103be576103bd610220565b5b6103ca8a828b01610234565b935093505060806103dd8a828b0161031b565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610426826102fa565b9150610431836102fa565b925082820261043f816102fa565b91508282048414831517610456576104556103ec565b5b5092915050565b610466816102aa565b82525050565b610475816102fa565b82525050565b6000606082019050610490600083018661045d565b61049d602083018561045d565b6104aa604083018461046c565b949350505050565b60006040820190506104c7600083018561045d565b6104d4602083018461046c565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051883856104db565b93506105258385846104ec565b61052e836104fb565b840190509392505050565b6000819050919050565b600061055e6105596105548461028a565b610539565b61028a565b9050919050565b600061057082610543565b9050919050565b600061058282610565565b9050919050565b61059281610577565b82525050565b600060808201905081810360008301526105b381888a61050c565b90506105c26020830187610589565b6105cf604083018661046c565b81810360608301526105e281848661050c565b9050979650505050505050565b60006105fa826102fa565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361062c5761062b6103ec565b5b60018201905091905056fea264697066735822122052c5caf083af6e05e3cd0c0e628630fe7cba46565021425413eabeb4a56b4b5464736f6c63430008150033", +} + +// DepositorABI is the input ABI used to generate the binding from. +// Deprecated: Use DepositorMetaData.ABI instead. +var DepositorABI = DepositorMetaData.ABI + +// DepositorBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DepositorMetaData.Bin instead. +var DepositorBin = DepositorMetaData.Bin + +// DeployDepositor deploys a new Ethereum contract, binding an instance of Depositor to it. +func DeployDepositor(auth *bind.TransactOpts, backend bind.ContractBackend, custody_ common.Address) (common.Address, *types.Transaction, *Depositor, error) { + parsed, err := DepositorMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DepositorBin), backend, custody_) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Depositor{DepositorCaller: DepositorCaller{contract: contract}, DepositorTransactor: DepositorTransactor{contract: contract}, DepositorFilterer: DepositorFilterer{contract: contract}}, nil +} + +// Depositor is an auto generated Go binding around an Ethereum contract. +type Depositor struct { + DepositorCaller // Read-only binding to the contract + DepositorTransactor // Write-only binding to the contract + DepositorFilterer // Log filterer for contract events +} + +// DepositorCaller is an auto generated read-only Go binding around an Ethereum contract. +type DepositorCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DepositorTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DepositorTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DepositorFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DepositorFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DepositorSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DepositorSession struct { + Contract *Depositor // 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 +} + +// DepositorCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DepositorCallerSession struct { + Contract *DepositorCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DepositorTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DepositorTransactorSession struct { + Contract *DepositorTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DepositorRaw is an auto generated low-level Go binding around an Ethereum contract. +type DepositorRaw struct { + Contract *Depositor // Generic contract binding to access the raw methods on +} + +// DepositorCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DepositorCallerRaw struct { + Contract *DepositorCaller // Generic read-only contract binding to access the raw methods on +} + +// DepositorTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DepositorTransactorRaw struct { + Contract *DepositorTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDepositor creates a new instance of Depositor, bound to a specific deployed contract. +func NewDepositor(address common.Address, backend bind.ContractBackend) (*Depositor, error) { + contract, err := bindDepositor(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Depositor{DepositorCaller: DepositorCaller{contract: contract}, DepositorTransactor: DepositorTransactor{contract: contract}, DepositorFilterer: DepositorFilterer{contract: contract}}, nil +} + +// NewDepositorCaller creates a new read-only instance of Depositor, bound to a specific deployed contract. +func NewDepositorCaller(address common.Address, caller bind.ContractCaller) (*DepositorCaller, error) { + contract, err := bindDepositor(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DepositorCaller{contract: contract}, nil +} + +// NewDepositorTransactor creates a new write-only instance of Depositor, bound to a specific deployed contract. +func NewDepositorTransactor(address common.Address, transactor bind.ContractTransactor) (*DepositorTransactor, error) { + contract, err := bindDepositor(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DepositorTransactor{contract: contract}, nil +} + +// NewDepositorFilterer creates a new log filterer instance of Depositor, bound to a specific deployed contract. +func NewDepositorFilterer(address common.Address, filterer bind.ContractFilterer) (*DepositorFilterer, error) { + contract, err := bindDepositor(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DepositorFilterer{contract: contract}, nil +} + +// bindDepositor binds a generic wrapper to an already deployed contract. +func bindDepositor(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := DepositorMetaData.GetAbi() + 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 (_Depositor *DepositorRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Depositor.Contract.DepositorCaller.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 (_Depositor *DepositorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Depositor.Contract.DepositorTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Depositor *DepositorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Depositor.Contract.DepositorTransactor.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 (_Depositor *DepositorCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Depositor.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 (_Depositor *DepositorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Depositor.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Depositor *DepositorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Depositor.Contract.contract.Transact(opts, method, params...) +} + +// RunDeposits is a paid mutator transaction binding the contract method 0x3d496c93. +// +// Solidity: function runDeposits(bytes recipient, address asset, uint256 amount, bytes message, uint256 count) returns() +func (_Depositor *DepositorTransactor) RunDeposits(opts *bind.TransactOpts, recipient []byte, asset common.Address, amount *big.Int, message []byte, count *big.Int) (*types.Transaction, error) { + return _Depositor.contract.Transact(opts, "runDeposits", recipient, asset, amount, message, count) +} + +// RunDeposits is a paid mutator transaction binding the contract method 0x3d496c93. +// +// Solidity: function runDeposits(bytes recipient, address asset, uint256 amount, bytes message, uint256 count) returns() +func (_Depositor *DepositorSession) RunDeposits(recipient []byte, asset common.Address, amount *big.Int, message []byte, count *big.Int) (*types.Transaction, error) { + return _Depositor.Contract.RunDeposits(&_Depositor.TransactOpts, recipient, asset, amount, message, count) +} + +// RunDeposits is a paid mutator transaction binding the contract method 0x3d496c93. +// +// Solidity: function runDeposits(bytes recipient, address asset, uint256 amount, bytes message, uint256 count) returns() +func (_Depositor *DepositorTransactorSession) RunDeposits(recipient []byte, asset common.Address, amount *big.Int, message []byte, count *big.Int) (*types.Transaction, error) { + return _Depositor.Contract.RunDeposits(&_Depositor.TransactOpts, recipient, asset, amount, message, count) +} diff --git a/testutil/contracts/Depositor.json b/testutil/contracts/Depositor.json new file mode 100644 index 0000000000..0cd3488806 --- /dev/null +++ b/testutil/contracts/Depositor.json @@ -0,0 +1,49 @@ +{ + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "custody_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "recipient", + "type": "bytes" + }, + { + "internalType": "contract IERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "runDeposits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "60a060405234801561001057600080fd5b5060405161078a38038061078a833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161066d61011d6000396000818160e4015261016b015261066d6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a60048036038101906100459190610330565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd33308488610076919061041b565b6040518463ffffffff1660e01b81526004016100949392919061047b565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f919061041b565b6040518363ffffffff1660e01b815260040161012c9291906104b2565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b81811015610211577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610598565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080610209906105ef565b915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261024a57610249610225565b5b8235905067ffffffffffffffff8111156102675761026661022a565b5b6020830191508360018202830111156102835761028261022f565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102b58261028a565b9050919050565b60006102c7826102aa565b9050919050565b6102d7816102bc565b81146102e257600080fd5b50565b6000813590506102f4816102ce565b92915050565b6000819050919050565b61030d816102fa565b811461031857600080fd5b50565b60008135905061032a81610304565b92915050565b600080600080600080600060a0888a03121561034f5761034e61021b565b5b600088013567ffffffffffffffff81111561036d5761036c610220565b5b6103798a828b01610234565b9750975050602061038c8a828b016102e5565b955050604061039d8a828b0161031b565b945050606088013567ffffffffffffffff8111156103be576103bd610220565b5b6103ca8a828b01610234565b935093505060806103dd8a828b0161031b565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610426826102fa565b9150610431836102fa565b925082820261043f816102fa565b91508282048414831517610456576104556103ec565b5b5092915050565b610466816102aa565b82525050565b610475816102fa565b82525050565b6000606082019050610490600083018661045d565b61049d602083018561045d565b6104aa604083018461046c565b949350505050565b60006040820190506104c7600083018561045d565b6104d4602083018461046c565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051883856104db565b93506105258385846104ec565b61052e836104fb565b840190509392505050565b6000819050919050565b600061055e6105596105548461028a565b610539565b61028a565b9050919050565b600061057082610543565b9050919050565b600061058282610565565b9050919050565b61059281610577565b82525050565b600060808201905081810360008301526105b381888a61050c565b90506105c26020830187610589565b6105cf604083018661046c565b81810360608301526105e281848661050c565b9050979650505050505050565b60006105fa826102fa565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361062c5761062b6103ec565b5b60018201905091905056fea264697066735822122052c5caf083af6e05e3cd0c0e628630fe7cba46565021425413eabeb4a56b4b5464736f6c63430008150033" +} diff --git a/testutil/contracts/Depositor.sol b/testutil/contracts/Depositor.sol new file mode 100644 index 0000000000..15163a5973 --- /dev/null +++ b/testutil/contracts/Depositor.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +interface IERC20 { + function approve(address spender, uint256 amount) external; + function transferFrom(address sender, address recipient, uint256 amount) external; +} + +interface ERC20Custody { + function deposit( + bytes calldata recipient, + IERC20 asset, + uint256 amount, + bytes calldata message + ) external; +} + +// Sample contract for running deposit on EVM +contract Depositor { + ERC20Custody immutable private _custody; + + constructor(address custody_) { + _custody = ERC20Custody(custody_); + } + + // Run n deposits of amount on asset to custody + function runDeposits( + bytes calldata recipient, + IERC20 asset, + uint256 amount, + bytes calldata message, + uint256 count + ) external { + asset.transferFrom(msg.sender, address(this), amount * count); + asset.approve(address(_custody), amount * count); + for (uint256 i = 0; i < count; i++) { + _custody.deposit(recipient, asset, amount, message); + } + } +} \ No newline at end of file diff --git a/testutil/contracts/Withdrawer.abi b/testutil/contracts/Withdrawer.abi new file mode 100644 index 0000000000..407b59e1a9 --- /dev/null +++ b/testutil/contracts/Withdrawer.abi @@ -0,0 +1,30 @@ +[ + { + "inputs": [ + { + "internalType": "bytes", + "name": "recipient", + "type": "bytes" + }, + { + "internalType": "contract IZRC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "runWithdraws", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/testutil/contracts/Withdrawer.bin b/testutil/contracts/Withdrawer.bin new file mode 100644 index 0000000000..3d5994f09b --- /dev/null +++ b/testutil/contracts/Withdrawer.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b5061075a806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ef565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104b8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd3330600a856100ee9190610527565b6040518463ffffffff1660e01b815260040161010c93929190610587565b600060405180830381600087803b15801561012657600080fd5b505af115801561013a573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b386600a846101689190610527565b6040518363ffffffff1660e01b81526004016101859291906105be565b600060405180830381600087803b15801561019f57600080fd5b505af11580156101b3573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101e19190610527565b6040518463ffffffff1660e01b81526004016101ff93929190610587565b600060405180830381600087803b15801561021957600080fd5b505af115801561022d573d6000803e3d6000fd5b5050505060005b838110156102d0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161027993929190610645565b6020604051808303816000875af1158015610298573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bc91906106af565b5080806102c8906106dc565b915050610234565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610309576103086102e4565b5b8235905067ffffffffffffffff811115610326576103256102e9565b5b602083019150836001820283011115610342576103416102ee565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061037482610349565b9050919050565b600061038682610369565b9050919050565b6103968161037b565b81146103a157600080fd5b50565b6000813590506103b38161038d565b92915050565b6000819050919050565b6103cc816103b9565b81146103d757600080fd5b50565b6000813590506103e9816103c3565b92915050565b60008060008060006080868803121561040b5761040a6102da565b5b600086013567ffffffffffffffff811115610429576104286102df565b5b610435888289016102f3565b95509550506020610448888289016103a4565b9350506040610459888289016103da565b925050606061046a888289016103da565b9150509295509295909350565b61048081610369565b811461048b57600080fd5b50565b60008151905061049d81610477565b92915050565b6000815190506104b2816103c3565b92915050565b600080604083850312156104cf576104ce6102da565b5b60006104dd8582860161048e565b92505060206104ee858286016104a3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610532826103b9565b915061053d836103b9565b925082820261054b816103b9565b91508282048414831517610562576105616104f8565b5b5092915050565b61057281610369565b82525050565b610581816103b9565b82525050565b600060608201905061059c6000830186610569565b6105a96020830185610569565b6105b66040830184610578565b949350505050565b60006040820190506105d36000830185610569565b6105e06020830184610578565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061062483856105e7565b93506106318385846105f8565b61063a83610607565b840190509392505050565b60006040820190508181036000830152610660818587610618565b905061066f6020830184610578565b949350505050565b60008115159050919050565b61068c81610677565b811461069757600080fd5b50565b6000815190506106a981610683565b92915050565b6000602082840312156106c5576106c46102da565b5b60006106d38482850161069a565b91505092915050565b60006106e7826103b9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610719576107186104f8565b5b60018201905091905056fea2646970667358221220facf63a05707c7ee9b4b53c5ddd9a2d42e779dd5790d95ba8e4526d32232b9d664736f6c63430008150033 diff --git a/testutil/contracts/Withdrawer.go b/testutil/contracts/Withdrawer.go new file mode 100644 index 0000000000..1c4e5f4350 --- /dev/null +++ b/testutil/contracts/Withdrawer.go @@ -0,0 +1,224 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +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 + _ = abi.ConvertType +) + +// WithdrawerMetaData contains all meta data concerning the Withdrawer contract. +var WithdrawerMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIZRC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runWithdraws\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5061075a806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ef565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104b8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd3330600a856100ee9190610527565b6040518463ffffffff1660e01b815260040161010c93929190610587565b600060405180830381600087803b15801561012657600080fd5b505af115801561013a573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b386600a846101689190610527565b6040518363ffffffff1660e01b81526004016101859291906105be565b600060405180830381600087803b15801561019f57600080fd5b505af11580156101b3573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101e19190610527565b6040518463ffffffff1660e01b81526004016101ff93929190610587565b600060405180830381600087803b15801561021957600080fd5b505af115801561022d573d6000803e3d6000fd5b5050505060005b838110156102d0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161027993929190610645565b6020604051808303816000875af1158015610298573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bc91906106af565b5080806102c8906106dc565b915050610234565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610309576103086102e4565b5b8235905067ffffffffffffffff811115610326576103256102e9565b5b602083019150836001820283011115610342576103416102ee565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061037482610349565b9050919050565b600061038682610369565b9050919050565b6103968161037b565b81146103a157600080fd5b50565b6000813590506103b38161038d565b92915050565b6000819050919050565b6103cc816103b9565b81146103d757600080fd5b50565b6000813590506103e9816103c3565b92915050565b60008060008060006080868803121561040b5761040a6102da565b5b600086013567ffffffffffffffff811115610429576104286102df565b5b610435888289016102f3565b95509550506020610448888289016103a4565b9350506040610459888289016103da565b925050606061046a888289016103da565b9150509295509295909350565b61048081610369565b811461048b57600080fd5b50565b60008151905061049d81610477565b92915050565b6000815190506104b2816103c3565b92915050565b600080604083850312156104cf576104ce6102da565b5b60006104dd8582860161048e565b92505060206104ee858286016104a3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610532826103b9565b915061053d836103b9565b925082820261054b816103b9565b91508282048414831517610562576105616104f8565b5b5092915050565b61057281610369565b82525050565b610581816103b9565b82525050565b600060608201905061059c6000830186610569565b6105a96020830185610569565b6105b66040830184610578565b949350505050565b60006040820190506105d36000830185610569565b6105e06020830184610578565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061062483856105e7565b93506106318385846105f8565b61063a83610607565b840190509392505050565b60006040820190508181036000830152610660818587610618565b905061066f6020830184610578565b949350505050565b60008115159050919050565b61068c81610677565b811461069757600080fd5b50565b6000815190506106a981610683565b92915050565b6000602082840312156106c5576106c46102da565b5b60006106d38482850161069a565b91505092915050565b60006106e7826103b9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610719576107186104f8565b5b60018201905091905056fea2646970667358221220facf63a05707c7ee9b4b53c5ddd9a2d42e779dd5790d95ba8e4526d32232b9d664736f6c63430008150033", +} + +// WithdrawerABI is the input ABI used to generate the binding from. +// Deprecated: Use WithdrawerMetaData.ABI instead. +var WithdrawerABI = WithdrawerMetaData.ABI + +// WithdrawerBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use WithdrawerMetaData.Bin instead. +var WithdrawerBin = WithdrawerMetaData.Bin + +// DeployWithdrawer deploys a new Ethereum contract, binding an instance of Withdrawer to it. +func DeployWithdrawer(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Withdrawer, error) { + parsed, err := WithdrawerMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(WithdrawerBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Withdrawer{WithdrawerCaller: WithdrawerCaller{contract: contract}, WithdrawerTransactor: WithdrawerTransactor{contract: contract}, WithdrawerFilterer: WithdrawerFilterer{contract: contract}}, nil +} + +// Withdrawer is an auto generated Go binding around an Ethereum contract. +type Withdrawer struct { + WithdrawerCaller // Read-only binding to the contract + WithdrawerTransactor // Write-only binding to the contract + WithdrawerFilterer // Log filterer for contract events +} + +// WithdrawerCaller is an auto generated read-only Go binding around an Ethereum contract. +type WithdrawerCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WithdrawerTransactor is an auto generated write-only Go binding around an Ethereum contract. +type WithdrawerTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WithdrawerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type WithdrawerFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WithdrawerSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type WithdrawerSession struct { + Contract *Withdrawer // 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 +} + +// WithdrawerCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type WithdrawerCallerSession struct { + Contract *WithdrawerCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// WithdrawerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type WithdrawerTransactorSession struct { + Contract *WithdrawerTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// WithdrawerRaw is an auto generated low-level Go binding around an Ethereum contract. +type WithdrawerRaw struct { + Contract *Withdrawer // Generic contract binding to access the raw methods on +} + +// WithdrawerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type WithdrawerCallerRaw struct { + Contract *WithdrawerCaller // Generic read-only contract binding to access the raw methods on +} + +// WithdrawerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type WithdrawerTransactorRaw struct { + Contract *WithdrawerTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewWithdrawer creates a new instance of Withdrawer, bound to a specific deployed contract. +func NewWithdrawer(address common.Address, backend bind.ContractBackend) (*Withdrawer, error) { + contract, err := bindWithdrawer(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Withdrawer{WithdrawerCaller: WithdrawerCaller{contract: contract}, WithdrawerTransactor: WithdrawerTransactor{contract: contract}, WithdrawerFilterer: WithdrawerFilterer{contract: contract}}, nil +} + +// NewWithdrawerCaller creates a new read-only instance of Withdrawer, bound to a specific deployed contract. +func NewWithdrawerCaller(address common.Address, caller bind.ContractCaller) (*WithdrawerCaller, error) { + contract, err := bindWithdrawer(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &WithdrawerCaller{contract: contract}, nil +} + +// NewWithdrawerTransactor creates a new write-only instance of Withdrawer, bound to a specific deployed contract. +func NewWithdrawerTransactor(address common.Address, transactor bind.ContractTransactor) (*WithdrawerTransactor, error) { + contract, err := bindWithdrawer(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &WithdrawerTransactor{contract: contract}, nil +} + +// NewWithdrawerFilterer creates a new log filterer instance of Withdrawer, bound to a specific deployed contract. +func NewWithdrawerFilterer(address common.Address, filterer bind.ContractFilterer) (*WithdrawerFilterer, error) { + contract, err := bindWithdrawer(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &WithdrawerFilterer{contract: contract}, nil +} + +// bindWithdrawer binds a generic wrapper to an already deployed contract. +func bindWithdrawer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := WithdrawerMetaData.GetAbi() + 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 (_Withdrawer *WithdrawerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Withdrawer.Contract.WithdrawerCaller.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 (_Withdrawer *WithdrawerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawer.Contract.WithdrawerTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Withdrawer *WithdrawerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Withdrawer.Contract.WithdrawerTransactor.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 (_Withdrawer *WithdrawerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Withdrawer.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 (_Withdrawer *WithdrawerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawer.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Withdrawer *WithdrawerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Withdrawer.Contract.contract.Transact(opts, method, params...) +} + +// RunWithdraws is a paid mutator transaction binding the contract method 0xe3be6f68. +// +// Solidity: function runWithdraws(bytes recipient, address asset, uint256 amount, uint256 count) returns() +func (_Withdrawer *WithdrawerTransactor) RunWithdraws(opts *bind.TransactOpts, recipient []byte, asset common.Address, amount *big.Int, count *big.Int) (*types.Transaction, error) { + return _Withdrawer.contract.Transact(opts, "runWithdraws", recipient, asset, amount, count) +} + +// RunWithdraws is a paid mutator transaction binding the contract method 0xe3be6f68. +// +// Solidity: function runWithdraws(bytes recipient, address asset, uint256 amount, uint256 count) returns() +func (_Withdrawer *WithdrawerSession) RunWithdraws(recipient []byte, asset common.Address, amount *big.Int, count *big.Int) (*types.Transaction, error) { + return _Withdrawer.Contract.RunWithdraws(&_Withdrawer.TransactOpts, recipient, asset, amount, count) +} + +// RunWithdraws is a paid mutator transaction binding the contract method 0xe3be6f68. +// +// Solidity: function runWithdraws(bytes recipient, address asset, uint256 amount, uint256 count) returns() +func (_Withdrawer *WithdrawerTransactorSession) RunWithdraws(recipient []byte, asset common.Address, amount *big.Int, count *big.Int) (*types.Transaction, error) { + return _Withdrawer.Contract.RunWithdraws(&_Withdrawer.TransactOpts, recipient, asset, amount, count) +} diff --git a/testutil/contracts/Withdrawer.json b/testutil/contracts/Withdrawer.json new file mode 100644 index 0000000000..eaedb8b992 --- /dev/null +++ b/testutil/contracts/Withdrawer.json @@ -0,0 +1,33 @@ +{ + "abi": [ + { + "inputs": [ + { + "internalType": "bytes", + "name": "recipient", + "type": "bytes" + }, + { + "internalType": "contract IZRC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "name": "runWithdraws", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "608060405234801561001057600080fd5b5061075a806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ef565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104b8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd3330600a856100ee9190610527565b6040518463ffffffff1660e01b815260040161010c93929190610587565b600060405180830381600087803b15801561012657600080fd5b505af115801561013a573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b386600a846101689190610527565b6040518363ffffffff1660e01b81526004016101859291906105be565b600060405180830381600087803b15801561019f57600080fd5b505af11580156101b3573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101e19190610527565b6040518463ffffffff1660e01b81526004016101ff93929190610587565b600060405180830381600087803b15801561021957600080fd5b505af115801561022d573d6000803e3d6000fd5b5050505060005b838110156102d0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161027993929190610645565b6020604051808303816000875af1158015610298573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102bc91906106af565b5080806102c8906106dc565b915050610234565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610309576103086102e4565b5b8235905067ffffffffffffffff811115610326576103256102e9565b5b602083019150836001820283011115610342576103416102ee565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061037482610349565b9050919050565b600061038682610369565b9050919050565b6103968161037b565b81146103a157600080fd5b50565b6000813590506103b38161038d565b92915050565b6000819050919050565b6103cc816103b9565b81146103d757600080fd5b50565b6000813590506103e9816103c3565b92915050565b60008060008060006080868803121561040b5761040a6102da565b5b600086013567ffffffffffffffff811115610429576104286102df565b5b610435888289016102f3565b95509550506020610448888289016103a4565b9350506040610459888289016103da565b925050606061046a888289016103da565b9150509295509295909350565b61048081610369565b811461048b57600080fd5b50565b60008151905061049d81610477565b92915050565b6000815190506104b2816103c3565b92915050565b600080604083850312156104cf576104ce6102da565b5b60006104dd8582860161048e565b92505060206104ee858286016104a3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610532826103b9565b915061053d836103b9565b925082820261054b816103b9565b91508282048414831517610562576105616104f8565b5b5092915050565b61057281610369565b82525050565b610581816103b9565b82525050565b600060608201905061059c6000830186610569565b6105a96020830185610569565b6105b66040830184610578565b949350505050565b60006040820190506105d36000830185610569565b6105e06020830184610578565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061062483856105e7565b93506106318385846105f8565b61063a83610607565b840190509392505050565b60006040820190508181036000830152610660818587610618565b905061066f6020830184610578565b949350505050565b60008115159050919050565b61068c81610677565b811461069757600080fd5b50565b6000815190506106a981610683565b92915050565b6000602082840312156106c5576106c46102da565b5b60006106d38482850161069a565b91505092915050565b60006106e7826103b9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610719576107186104f8565b5b60018201905091905056fea2646970667358221220facf63a05707c7ee9b4b53c5ddd9a2d42e779dd5790d95ba8e4526d32232b9d664736f6c63430008150033" +} diff --git a/testutil/contracts/Withdrawer.sol b/testutil/contracts/Withdrawer.sol new file mode 100644 index 0000000000..cc19e29391 --- /dev/null +++ b/testutil/contracts/Withdrawer.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +interface IZRC20 { + function approve(address spender, uint256 amount) external; + function transferFrom(address sender, address recipient, uint256 amount) external; + function withdraw(bytes memory to, uint256 amount) external returns (bool); + function withdrawGasFee() external returns (address, uint256); +} + +// Sample contract for running withdraw on zEVM +contract Withdrawer { + // Run n withdraws of amount on asset to custody + function runWithdraws( + bytes calldata recipient, + IZRC20 asset, + uint256 amount, + uint256 count + ) external { + // transfer gas for the transactions and approve it in the zrc20 + (address gas, uint256 gasFee) = asset.withdrawGasFee(); + IZRC20(gas).transferFrom(msg.sender, address(this), gasFee * 10); + IZRC20(gas).approve(address(asset), gasFee * 10); + + // perform the withdraws + asset.transferFrom(msg.sender, address(this), amount * count); + for (uint256 i = 0; i < count; i++) { + asset.withdraw(recipient, amount); + } + } +} \ No newline at end of file diff --git a/testutil/contracts/bindings.go b/testutil/contracts/bindings.go index bb64d01778..88052fa2b2 100644 --- a/testutil/contracts/bindings.go +++ b/testutil/contracts/bindings.go @@ -10,4 +10,16 @@ //go:generate sh -c "cat Reverter.json | jq .bin | tr -d '\"' > Reverter.bin" //go:generate sh -c "abigen --abi Reverter.abi --bin Reverter.bin --pkg contracts --type Reverter --out Reverter.go" +// Depositor +//go:generate sh -c "solc --evm-version paris Depositor.sol --combined-json abi,bin | jq '.contracts.\"Depositor.sol:Depositor\"' > Depositor.json" +//go:generate sh -c "cat Depositor.json | jq .abi > Depositor.abi" +//go:generate sh -c "cat Depositor.json | jq .bin | tr -d '\"' > Depositor.bin" +//go:generate sh -c "abigen --abi Depositor.abi --bin Depositor.bin --pkg contracts --type Depositor --out Depositor.go" + +// Withdrawer +//go:generate sh -c "solc --evm-version paris Withdrawer.sol --combined-json abi,bin | jq '.contracts.\"Withdrawer.sol:Withdrawer\"' > Withdrawer.json" +//go:generate sh -c "cat Withdrawer.json | jq .abi > Withdrawer.abi" +//go:generate sh -c "cat Withdrawer.json | jq .bin | tr -d '\"' > Withdrawer.bin" +//go:generate sh -c "abigen --abi Withdrawer.abi --bin Withdrawer.bin --pkg contracts --type Withdrawer --out Withdrawer.go" + package contracts diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index 0cb2a31bb2..2bc0eed3a0 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -55,6 +55,7 @@ func CrosschainKeeperWithMocks( db, stateStore, sdkKeepers.StakingKeeper, + sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, ) fungiblekeeperTmp := initFungibleKeeper( diff --git a/testutil/keeper/fungible.go b/testutil/keeper/fungible.go index 6f26a2733e..b4caebbc88 100644 --- a/testutil/keeper/fungible.go +++ b/testutil/keeper/fungible.go @@ -80,6 +80,7 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke db, stateStore, sdkKeepers.StakingKeeper, + sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, ) zetaKeepers := ZetaKeepers{ diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index 2868f86941..b67e310544 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -5,6 +5,9 @@ import ( "testing" "time" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -81,6 +84,7 @@ type SDKKeepers struct { AuthKeeper authkeeper.AccountKeeper BankKeeper bankkeeper.Keeper StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper FeeMarketKeeper feemarketkeeper.Keeper EvmKeeper *evmkeeper.Keeper } @@ -199,6 +203,13 @@ func StakingKeeper( ) } +// SlashingKeeper instantiates a slashing keeper for testing purposes +func SlashingKeeper(cdc codec.Codec, db *tmdb.MemDB, ss store.CommitMultiStore, stakingKeeper stakingkeeper.Keeper, paramKeeper paramskeeper.Keeper) slashingkeeper.Keeper { + storeKey := sdk.NewKVStoreKey(slashingtypes.StoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + return slashingkeeper.NewKeeper(cdc, storeKey, stakingKeeper, paramKeeper.Subspace(slashingtypes.ModuleName)) +} + // DistributionKeeper instantiates a distribution keeper for testing purposes func DistributionKeeper( cdc codec.Codec, @@ -319,7 +330,7 @@ func NewSDKKeepers( stakingKeeper := StakingKeeper(cdc, db, ss, authKeeper, bankKeeper, paramsKeeper) feeMarketKeeper := FeeMarketKeeper(cdc, db, ss, paramsKeeper) evmKeeper := EVMKeeper(cdc, db, ss, authKeeper, bankKeeper, stakingKeeper, feeMarketKeeper, paramsKeeper) - + slashingKeeper := SlashingKeeper(cdc, db, ss, stakingKeeper, paramsKeeper) return SDKKeepers{ ParamsKeeper: paramsKeeper, AuthKeeper: authKeeper, @@ -327,6 +338,7 @@ func NewSDKKeepers( StakingKeeper: stakingKeeper, FeeMarketKeeper: feeMarketKeeper, EvmKeeper: evmKeeper, + SlashingKeeper: slashingKeeper, } } diff --git a/testutil/keeper/observer.go b/testutil/keeper/observer.go index 417decd0ca..946dac84c6 100644 --- a/testutil/keeper/observer.go +++ b/testutil/keeper/observer.go @@ -3,6 +3,8 @@ package keeper import ( "testing" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -20,6 +22,7 @@ func initObserverKeeper( db *tmdb.MemDB, ss store.CommitMultiStore, stakingKeeper stakingkeeper.Keeper, + slashingKeeper slashingkeeper.Keeper, paramKeeper paramskeeper.Keeper, ) *keeper.Keeper { storeKey := sdk.NewKVStoreKey(types.StoreKey) @@ -33,6 +36,7 @@ func initObserverKeeper( memKey, paramKeeper.Subspace(types.ModuleName), stakingKeeper, + slashingKeeper, ) } @@ -68,6 +72,7 @@ func ObserverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { memStoreKey, sdkKeepers.ParamsKeeper.Subspace(types.ModuleName), sdkKeepers.StakingKeeper, + sdkKeepers.SlashingKeeper, ) k.SetParams(ctx, types.DefaultParams()) diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index ff1596e88d..fdf92888b3 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -15,7 +15,7 @@ import ( "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/x/crosschain/types" - observerTypes "github.com/zeta-chain/zetacore/x/observer/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage, codec codec.Codec, observerList []string, setupChainNonces bool) { @@ -23,16 +23,16 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage // Cross-chain genesis state var crossChainGenesis types.GenesisState assert.NoError(t, codec.UnmarshalJSON(genesisState[types.ModuleName], &crossChainGenesis)) - nodeAccountList := make([]*observerTypes.NodeAccount, len(observerList)) + nodeAccountList := make([]*observertypes.NodeAccount, len(observerList)) for i, operator := range observerList { - nodeAccountList[i] = &observerTypes.NodeAccount{ + nodeAccountList[i] = &observertypes.NodeAccount{ Operator: operator, - NodeStatus: observerTypes.NodeStatus_Active, + NodeStatus: observertypes.NodeStatus_Active, } } if setupChainNonces { - chainNonceList := make([]*types.ChainNonces, len(common.DefaultChainsList())) - for i, chain := range common.DefaultChainsList() { + chainNonceList := make([]*types.ChainNonces, len(common.PrivnetChainList())) + for i, chain := range common.PrivnetChainList() { chainNonceList[i] = &types.ChainNonces{ Index: chain.ChainName.String(), ChainId: chain.ChainId, @@ -63,52 +63,63 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage assert.NoError(t, err) // Observer genesis state - var observerGenesis observerTypes.GenesisState - assert.NoError(t, codec.UnmarshalJSON(genesisState[observerTypes.ModuleName], &observerGenesis)) - observerMapper := make([]*observerTypes.ObserverMapper, len(common.DefaultChainsList())) + var observerGenesis observertypes.GenesisState + assert.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &observerGenesis)) + observerMapper := make([]*observertypes.ObserverMapper, len(common.PrivnetChainList())) - for i, chain := range common.DefaultChainsList() { - observerMapper[i] = &observerTypes.ObserverMapper{ + for i, chain := range common.PrivnetChainList() { + observerMapper[i] = &observertypes.ObserverMapper{ ObserverChain: chain, ObserverList: observerList, } } observerGenesis.Observers = observerMapper observerGenesis.NodeAccountList = nodeAccountList - observerGenesis.Keygen = &observerTypes.Keygen{ - Status: observerTypes.KeygenStatus_PendingKeygen, + observerGenesis.Keygen = &observertypes.Keygen{ + Status: observertypes.KeygenStatus_PendingKeygen, GranteePubkeys: observerList, BlockNumber: 5, } - assert.NoError(t, observerGenesis.Validate()) - observerGenesis.CrosschainFlags = &observerTypes.CrosschainFlags{ + // set admin policy with first validator as admin + observerGenesis.Params.AdminPolicy = []*observertypes.Admin_Policy{ + { + PolicyType: observertypes.Policy_Type_group1, + Address: "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + }, + { + PolicyType: observertypes.Policy_Type_group2, + Address: "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + }, + } + observerGenesis.CrosschainFlags = &observertypes.CrosschainFlags{ IsInboundEnabled: true, IsOutboundEnabled: true, } + assert.NoError(t, observerGenesis.Validate()) observerGenesisBz, err := codec.MarshalJSON(&observerGenesis) assert.NoError(t, err) genesisState[types.ModuleName] = crossChainGenesisBz genesisState[stakingtypes.ModuleName] = stakingGenesisStateBz - genesisState[observerTypes.ModuleName] = observerGenesisBz + genesisState[observertypes.ModuleName] = observerGenesisBz genesisState[evmtypes.ModuleName] = evmGenesisBz } -func AddObserverData(t *testing.T, genesisState map[string]json.RawMessage, codec codec.Codec, ballots []*observerTypes.Ballot) *observerTypes.GenesisState { - state := observerTypes.GenesisState{} - assert.NoError(t, codec.UnmarshalJSON(genesisState[observerTypes.ModuleName], &state)) +func AddObserverData(t *testing.T, genesisState map[string]json.RawMessage, codec codec.Codec, ballots []*observertypes.Ballot) *observertypes.GenesisState { + state := observertypes.GenesisState{} + assert.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &state)) if len(ballots) > 0 { state.Ballots = ballots } //params := observerTypes.DefaultParams() //params.BallotMaturityBlocks = 3 state.Params.BallotMaturityBlocks = 3 - state.Keygen = &observerTypes.Keygen{BlockNumber: 10, GranteePubkeys: []string{}} - crosschainFlags := &observerTypes.CrosschainFlags{ + state.Keygen = &observertypes.Keygen{BlockNumber: 10, GranteePubkeys: []string{}} + crosschainFlags := &observertypes.CrosschainFlags{ IsInboundEnabled: true, IsOutboundEnabled: true, - GasPriceIncreaseFlags: &observerTypes.DefaultGasPriceIncreaseFlags, - BlockHeaderVerificationFlags: &observerTypes.DefaultBlockHeaderVerificationFlags, + GasPriceIncreaseFlags: &observertypes.DefaultGasPriceIncreaseFlags, + BlockHeaderVerificationFlags: &observertypes.DefaultBlockHeaderVerificationFlags, } nullify.Fill(&crosschainFlags) @@ -118,7 +129,7 @@ func AddObserverData(t *testing.T, genesisState map[string]json.RawMessage, code buf, err := codec.MarshalJSON(&state) assert.NoError(t, err) - genesisState[observerTypes.ModuleName] = buf + genesisState[observertypes.ModuleName] = buf return &state } func AddCrosschainData(t *testing.T, n int, genesisState map[string]json.RawMessage, codec codec.Codec) *types.GenesisState { diff --git a/testutil/network/util.go b/testutil/network/util.go index 4354e98155..e6ee8fae25 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -202,7 +202,7 @@ func writeFile(name string, dir string, contents []byte) error { return err } - err = os.WriteFile(file, contents, 0644) // #nosec + err = os.WriteFile(file, contents, 0600) if err != nil { return err } diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 3e1d4c7208..6bf81a8b0b 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -91,7 +91,7 @@ func CoreParams(chainID int64) *types.CoreParams { } func CoreParamsList() (cpl types.CoreParamsList) { - chainList := common.DefaultChainsList() + chainList := common.PrivnetChainList() for _, chain := range chainList { cpl.CoreParams = append(cpl.CoreParams, CoreParams(chain.ChainId)) diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 2eef2b61b0..9085e7350c 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -53,6 +53,10 @@ func AccAddress() string { return sdk.AccAddress(addr).String() } +func ConsAddress() sdk.ConsAddress { + return sdk.ConsAddress(PubKey(newRandFromSeed(1)).Address()) +} + // ValAddress returns a sample validator operator address func ValAddress(r *rand.Rand) sdk.ValAddress { return sdk.ValAddress(PubKey(r).Address()) @@ -96,6 +100,11 @@ func EthAddress() ethcommon.Address { return ethcommon.BytesToAddress(sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()).Bytes()) } +// Hash returns a sample hash +func Hash() ethcommon.Hash { + return EthAddress().Hash() +} + // Bytes returns a sample byte array func Bytes() []byte { return []byte("sample") diff --git a/typescript/crosschain/query_pb.d.ts b/typescript/crosschain/query_pb.d.ts index 0446c27b90..73da28a31c 100644 --- a/typescript/crosschain/query_pb.d.ts +++ b/typescript/crosschain/query_pb.d.ts @@ -5,18 +5,66 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; +import type { CctxStatus, CrossChainTx } from "./cross_chain_tx_pb.js"; import type { TSS } from "./tss_pb.js"; import type { Params } from "./params_pb.js"; import type { OutTxTracker } from "./out_tx_tracker_pb.js"; import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; import type { InTxTracker } from "./in_tx_tracker_pb.js"; import type { InTxHashToCctx } from "./in_tx_hash_to_cctx_pb.js"; -import type { CrossChainTx } from "./cross_chain_tx_pb.js"; import type { GasPrice } from "./gas_price_pb.js"; import type { ChainNonces } from "./chain_nonces_pb.js"; import type { PendingNonces } from "./nonce_to_cctx_pb.js"; import type { LastBlockHeight } from "./last_block_height_pb.js"; +/** + * @generated from message zetachain.zetacore.crosschain.QueryCctxByStatusRequest + */ +export declare class QueryCctxByStatusRequest extends Message { + /** + * @generated from field: zetachain.zetacore.crosschain.CctxStatus status = 1; + */ + status: CctxStatus; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryCctxByStatusRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryCctxByStatusRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryCctxByStatusRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryCctxByStatusRequest; + + static equals(a: QueryCctxByStatusRequest | PlainMessage | undefined, b: QueryCctxByStatusRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.QueryCctxByStatusResponse + */ +export declare class QueryCctxByStatusResponse extends Message { + /** + * @generated from field: repeated zetachain.zetacore.crosschain.CrossChainTx CrossChainTx = 1; + */ + CrossChainTx: CrossChainTx[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryCctxByStatusResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryCctxByStatusResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryCctxByStatusResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryCctxByStatusResponse; + + static equals(a: QueryCctxByStatusResponse | PlainMessage | undefined, b: QueryCctxByStatusResponse | PlainMessage | undefined): boolean; +} + /** * @generated from message zetachain.zetacore.crosschain.QueryTssHistoryRequest */ @@ -532,6 +580,11 @@ export declare class QueryGetTssAddressRequest extends Message); static readonly runtime: typeof proto3; diff --git a/typescript/crosschain/tx_pb.d.ts b/typescript/crosschain/tx_pb.d.ts index 98f7fd5c3a..23ed750398 100644 --- a/typescript/crosschain/tx_pb.d.ts +++ b/typescript/crosschain/tx_pb.d.ts @@ -742,6 +742,13 @@ export declare class MsgVoteOnObservedInboundTx extends Message); static readonly runtime: typeof proto3; diff --git a/typescript/fungible/events_pb.d.ts b/typescript/fungible/events_pb.d.ts index c36e4eebd8..b34248d4aa 100644 --- a/typescript/fungible/events_pb.d.ts +++ b/typescript/fungible/events_pb.d.ts @@ -214,3 +214,101 @@ export declare class EventZRC20PausedStatusUpdated extends Message | undefined, b: EventZRC20PausedStatusUpdated | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.fungible.EventSystemContractsDeployed + */ +export declare class EventSystemContractsDeployed extends Message { + /** + * @generated from field: string msg_type_url = 1; + */ + msgTypeUrl: string; + + /** + * @generated from field: string uniswap_v2_factory = 2; + */ + uniswapV2Factory: string; + + /** + * @generated from field: string wzeta = 3; + */ + wzeta: string; + + /** + * @generated from field: string uniswap_v2_router = 4; + */ + uniswapV2Router: string; + + /** + * @generated from field: string connector_zevm = 5; + */ + connectorZevm: string; + + /** + * @generated from field: string system_contract = 6; + */ + systemContract: string; + + /** + * @generated from field: string signer = 7; + */ + signer: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.EventSystemContractsDeployed"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): EventSystemContractsDeployed; + + static fromJson(jsonValue: JsonValue, options?: Partial): EventSystemContractsDeployed; + + static fromJsonString(jsonString: string, options?: Partial): EventSystemContractsDeployed; + + static equals(a: EventSystemContractsDeployed | PlainMessage | undefined, b: EventSystemContractsDeployed | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.EventBytecodeUpdated + */ +export declare class EventBytecodeUpdated extends Message { + /** + * @generated from field: string msg_type_url = 1; + */ + msgTypeUrl: string; + + /** + * @generated from field: string contract_address = 2; + */ + contractAddress: string; + + /** + * @generated from field: string new_bytecode_hash = 3; + */ + newBytecodeHash: string; + + /** + * @generated from field: string old_bytecode_hash = 4; + */ + oldBytecodeHash: string; + + /** + * @generated from field: string signer = 5; + */ + signer: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.EventBytecodeUpdated"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): EventBytecodeUpdated; + + static fromJson(jsonValue: JsonValue, options?: Partial): EventBytecodeUpdated; + + static fromJsonString(jsonString: string, options?: Partial): EventBytecodeUpdated; + + static equals(a: EventBytecodeUpdated | PlainMessage | undefined, b: EventBytecodeUpdated | PlainMessage | undefined): boolean; +} + diff --git a/typescript/fungible/query_pb.d.ts b/typescript/fungible/query_pb.d.ts index 4a604e405e..57b15066b9 100644 --- a/typescript/fungible/query_pb.d.ts +++ b/typescript/fungible/query_pb.d.ts @@ -371,3 +371,51 @@ export declare class QueryAllGasStabilityPoolBalanceResponse_Balance extends Mes static equals(a: QueryAllGasStabilityPoolBalanceResponse_Balance | PlainMessage | undefined, b: QueryAllGasStabilityPoolBalanceResponse_Balance | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.fungible.QueryCodeHashRequest + */ +export declare class QueryCodeHashRequest extends Message { + /** + * @generated from field: string address = 1; + */ + address: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.QueryCodeHashRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryCodeHashRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryCodeHashRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryCodeHashRequest; + + static equals(a: QueryCodeHashRequest | PlainMessage | undefined, b: QueryCodeHashRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.QueryCodeHashResponse + */ +export declare class QueryCodeHashResponse extends Message { + /** + * @generated from field: string code_hash = 1; + */ + codeHash: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.QueryCodeHashResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryCodeHashResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryCodeHashResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryCodeHashResponse; + + static equals(a: QueryCodeHashResponse | PlainMessage | undefined, b: QueryCodeHashResponse | PlainMessage | undefined): boolean; +} + diff --git a/typescript/fungible/tx_pb.d.ts b/typescript/fungible/tx_pb.d.ts index fcb7f77343..e20d4bde71 100644 --- a/typescript/fungible/tx_pb.d.ts +++ b/typescript/fungible/tx_pb.d.ts @@ -22,6 +22,74 @@ export declare enum UpdatePausedStatusAction { UNPAUSE = 1, } +/** + * @generated from message zetachain.zetacore.fungible.MsgDeploySystemContracts + */ +export declare class MsgDeploySystemContracts extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.MsgDeploySystemContracts"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDeploySystemContracts; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDeploySystemContracts; + + static fromJsonString(jsonString: string, options?: Partial): MsgDeploySystemContracts; + + static equals(a: MsgDeploySystemContracts | PlainMessage | undefined, b: MsgDeploySystemContracts | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.MsgDeploySystemContractsResponse + */ +export declare class MsgDeploySystemContractsResponse extends Message { + /** + * @generated from field: string uniswapV2Factory = 1; + */ + uniswapV2Factory: string; + + /** + * @generated from field: string wzeta = 2; + */ + wzeta: string; + + /** + * @generated from field: string uniswapV2Router = 3; + */ + uniswapV2Router: string; + + /** + * @generated from field: string connectorZEVM = 4; + */ + connectorZEVM: string; + + /** + * @generated from field: string systemContract = 5; + */ + systemContract: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.MsgDeploySystemContractsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDeploySystemContractsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDeploySystemContractsResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgDeploySystemContractsResponse; + + static equals(a: MsgDeploySystemContractsResponse | PlainMessage | undefined, b: MsgDeploySystemContractsResponse | PlainMessage | undefined): boolean; +} + /** * @generated from message zetachain.zetacore.fungible.MsgUpdateZRC20WithdrawFee */ @@ -276,9 +344,9 @@ export declare class MsgUpdateContractBytecode extends Message); @@ -299,11 +367,6 @@ export declare class MsgUpdateContractBytecode extends Message { - /** - * @generated from field: bytes new_bytecode_hash = 1; - */ - newBytecodeHash: Uint8Array; - constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/typescript/observer/block_header_pb.d.ts b/typescript/observer/block_header_pb.d.ts new file mode 100644 index 0000000000..87f3e1d24d --- /dev/null +++ b/typescript/observer/block_header_pb.d.ts @@ -0,0 +1,47 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file observer/block_header.proto (package zetachain.zetacore.observer, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message zetachain.zetacore.observer.BlockHeaderState + */ +export declare class BlockHeaderState extends Message { + /** + * @generated from field: int64 chain_id = 1; + */ + chainId: bigint; + + /** + * @generated from field: int64 latest_height = 2; + */ + latestHeight: bigint; + + /** + * @generated from field: int64 earliest_height = 3; + */ + earliestHeight: bigint; + + /** + * @generated from field: bytes latest_block_hash = 4; + */ + latestBlockHash: Uint8Array; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.BlockHeaderState"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): BlockHeaderState; + + static fromJson(jsonValue: JsonValue, options?: Partial): BlockHeaderState; + + static fromJsonString(jsonString: string, options?: Partial): BlockHeaderState; + + static equals(a: BlockHeaderState | PlainMessage | undefined, b: BlockHeaderState | PlainMessage | undefined): boolean; +} + diff --git a/typescript/observer/observer_pb.d.ts b/typescript/observer/observer_pb.d.ts index 60f70c21cb..d348caf97e 100644 --- a/typescript/observer/observer_pb.d.ts +++ b/typescript/observer/observer_pb.d.ts @@ -37,6 +37,26 @@ export declare enum ObservationType { TSSKeySign = 4, } +/** + * @generated from enum zetachain.zetacore.observer.ObserverUpdateReason + */ +export declare enum ObserverUpdateReason { + /** + * @generated from enum value: Undefined = 0; + */ + Undefined = 0, + + /** + * @generated from enum value: Tombstoned = 1; + */ + Tombstoned = 1, + + /** + * @generated from enum value: AdminUpdate = 2; + */ + AdminUpdate = 2, +} + /** * @generated from message zetachain.zetacore.observer.ObserverMapper */ diff --git a/typescript/observer/tx_pb.d.ts b/typescript/observer/tx_pb.d.ts index c1933dd04f..47e1512fbb 100644 --- a/typescript/observer/tx_pb.d.ts +++ b/typescript/observer/tx_pb.d.ts @@ -5,11 +5,70 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; +import type { ObserverUpdateReason } from "./observer_pb.js"; import type { HeaderData } from "../common/common_pb.js"; import type { CoreParams } from "./params_pb.js"; import type { Blame } from "./blame_pb.js"; import type { BlockHeaderVerificationFlags, GasPriceIncreaseFlags } from "./crosschain_flags_pb.js"; +/** + * @generated from message zetachain.zetacore.observer.MsgUpdateObserver + */ +export declare class MsgUpdateObserver extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: string old_observer_address = 2; + */ + oldObserverAddress: string; + + /** + * @generated from field: string new_observer_address = 3; + */ + newObserverAddress: string; + + /** + * @generated from field: zetachain.zetacore.observer.ObserverUpdateReason update_reason = 4; + */ + updateReason: ObserverUpdateReason; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.MsgUpdateObserver"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateObserver; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateObserver; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateObserver; + + static equals(a: MsgUpdateObserver | PlainMessage | undefined, b: MsgUpdateObserver | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.observer.MsgUpdateObserverResponse + */ +export declare class MsgUpdateObserverResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.observer.MsgUpdateObserverResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateObserverResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateObserverResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateObserverResponse; + + static equals(a: MsgUpdateObserverResponse | PlainMessage | undefined, b: MsgUpdateObserverResponse | PlainMessage | undefined): boolean; +} + /** * @generated from message zetachain.zetacore.observer.MsgAddBlockHeader */ diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index 070764ca44..b97bc649f2 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -113,9 +113,10 @@ func CmdShowSend() *cobra.Command { func CmdCCTXInboundVoter() *cobra.Command { cmd := &cobra.Command{ - Use: "inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset]", + Use: "inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message" + + "] [inTxHash] [inBlockHeight] [coinType] [asset] [eventIndex]", Short: "Broadcast message sendVoter", - Args: cobra.ExactArgs(11), + Args: cobra.ExactArgs(12), RunE: func(cmd *cobra.Command, args []string) error { argsSender := args[0] argsSenderChain, err := strconv.ParseInt(args[1], 10, 64) @@ -147,6 +148,12 @@ func CmdCCTXInboundVoter() *cobra.Command { argsAsset := args[10] + // parse argsp[11] to uint type and not uint64 + argsEventIndex, err := strconv.ParseUint(args[11], 10, 32) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -166,6 +173,7 @@ func CmdCCTXInboundVoter() *cobra.Command { 250_000, argsCoinType, argsAsset, + uint(argsEventIndex), ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/crosschain/client/integrationtests/cli_helpers.go b/x/crosschain/client/integrationtests/cli_helpers.go index e86f1021c5..71c8a43a59 100644 --- a/x/crosschain/client/integrationtests/cli_helpers.go +++ b/x/crosschain/client/integrationtests/cli_helpers.go @@ -1,6 +1,3 @@ -//go:build TESTNET -// +build TESTNET - package integrationtests import ( @@ -9,22 +6,24 @@ import ( "strconv" "testing" + fungiblecli "github.com/zeta-chain/zetacore/x/fungible/client/cli" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" sdk "github.com/cosmos/cosmos-sdk/types" authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" tmcli "github.com/tendermint/tendermint/libs/cli" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/network" - "github.com/zeta-chain/zetacore/x/crosschain/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/testutil" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/zeta-chain/zetacore/x/crosschain/client/cli" + "github.com/zeta-chain/zetacore/x/crosschain/types" ) func TxSignExec(clientCtx client.Context, from fmt.Stringer, filename string, extraArgs ...string) (testutil.BufferWriter, error) { @@ -71,14 +70,95 @@ func GetTempDir(t testing.TB) string { // this change's rationale. tempdir, err := os.MkdirTemp("", "") require.NoError(t, err) - t.Cleanup(func() { _ = os.RemoveAll(tempdir) }) + t.Cleanup(func() { + err := os.RemoveAll(tempdir) + require.NoError(t, err) + }) return tempdir } +func BuildSignedDeploySystemContract(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI) *os.File { + cmd := fungiblecli.CmdDeploySystemContracts() + txArgs := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(100))).String()), + // gas limit + fmt.Sprintf("--%s=%d", flags.FlagGas, 4000000), + } + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, txArgs) + require.NoError(t, err) + unsignerdTx := WriteToNewTempFile(t, out.String()) + res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), + "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) + require.NoError(t, err) + return WriteToNewTempFile(t, res.String()) +} + +func BuildSignedUpdateSystemContract( + t testing.TB, + val *network.Validator, + denom string, + account authtypes.AccountI, + systemContractAddress string, +) *os.File { + cmd := fungiblecli.CmdUpdateSystemContract() + txArgs := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(100))).String()), + // gas limit + fmt.Sprintf("--%s=%d", flags.FlagGas, 4000000), + } + args := append([]string{systemContractAddress}, txArgs...) + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) + require.NoError(t, err) + unsignerdTx := WriteToNewTempFile(t, out.String()) + res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), + "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) + require.NoError(t, err) + return WriteToNewTempFile(t, res.String()) +} + +func BuildSignedDeployETHZRC20( + t testing.TB, + val *network.Validator, + denom string, + account authtypes.AccountI, +) *os.File { + cmd := fungiblecli.CmdDeployFungibleCoinZRC4() + txArgs := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(100))).String()), + // gas limit + fmt.Sprintf("--%s=%d", flags.FlagGas, 10000000), + } + args := append([]string{ + "", + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), + "18", + "ETH", + "gETH", + strconv.FormatInt(int64(common.CoinType_Gas), 10), + "1000000", + }, txArgs...) + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) + require.NoError(t, err) + unsignerdTx := WriteToNewTempFile(t, out.String()) + res, err := TxSignExec(val.ClientCtx, val.Address, unsignerdTx.Name(), + "--offline", "--account-number", strconv.FormatUint(account.GetAccountNumber(), 10), "--sequence", strconv.FormatUint(account.GetSequence(), 10)) + require.NoError(t, err) + return WriteToNewTempFile(t, res.String()) +} + func BuildSignedGasPriceVote(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI) *os.File { cmd := cli.CmdGasPriceVoter() inboundVoterArgs := []string{ - strconv.FormatInt(common.GoerliChain().ChainId, 10), + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), "10000000000", "100", "100", @@ -103,7 +183,7 @@ func BuildSignedTssVote(t testing.TB, val *network.Validator, denom string, acco cmd := cli.CmdCreateTSSVoter() inboundVoterArgs := []string{ "tsspubkey", - strconv.FormatInt(common.GoerliChain().ChainId, 10), + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), "0", } txArgs := []string{ @@ -122,8 +202,17 @@ func BuildSignedTssVote(t testing.TB, val *network.Validator, denom string, acco return WriteToNewTempFile(t, res.String()) } -func BuildSignedOutboundVote(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI, nonce uint64, - cctxIndex, outTxHash, valueReceived, status string) *os.File { +func BuildSignedOutboundVote( + t testing.TB, + val *network.Validator, + denom string, + account authtypes.AccountI, + nonce uint64, + cctxIndex, + outTxHash, + valueReceived, + status string, +) *os.File { cmd := cli.CmdCCTXOutboundVoter() outboundVoterArgs := []string{ cctxIndex, @@ -134,7 +223,7 @@ func BuildSignedOutboundVote(t testing.TB, val *network.Validator, denom string, "0", valueReceived, status, - strconv.FormatInt(common.GoerliChain().ChainId, 10), + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), strconv.FormatUint(nonce, 10), "Zeta", } @@ -159,16 +248,17 @@ func BuildSignedInboundVote(t testing.TB, val *network.Validator, denom string, cmd := cli.CmdCCTXInboundVoter() inboundVoterArgs := []string{ "0x96B05C238b99768F349135de0653b687f9c13fEE", - strconv.FormatInt(common.GoerliChain().ChainId, 10), + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", "0x96B05C238b99768F349135de0653b687f9c13fEE", - strconv.FormatInt(common.GoerliChain().ChainId, 10), + strconv.FormatInt(common.GoerliLocalnetChain().ChainId, 10), "10000000000000000000", message, "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", "100", "Zeta", "", + "0", } txArgs := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), @@ -190,10 +280,10 @@ func GetBallotIdentifier(message string) string { msg := types.NewMsgVoteOnObservedInboundTx( "", "0x96B05C238b99768F349135de0653b687f9c13fEE", - common.GoerliChain().ChainId, + common.GoerliLocalnetChain().ChainId, "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", "0x96B05C238b99768F349135de0653b687f9c13fEE", - common.GoerliChain().ChainId, + common.GoerliLocalnetChain().ChainId, sdk.NewUint(10000000000000000000), message, "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", @@ -201,6 +291,7 @@ func GetBallotIdentifier(message string) string { 250_000, common.CoinType_Zeta, "", + 0, ) return msg.Digest() } @@ -216,7 +307,7 @@ func GetBallotIdentifierOutBound(nonce uint64, cctxindex, outtxHash, valueReceiv 0, math.NewUintFromString(valueReceived), 0, - common.GoerliChain().ChainId, + common.GoerliLocalnetChain().ChainId, nonce, common.CoinType_Zeta, ) diff --git a/x/crosschain/client/integrationtests/cli_test.go b/x/crosschain/client/integrationtests/cli_test.go index cd5af20871..de594398ce 100644 --- a/x/crosschain/client/integrationtests/cli_test.go +++ b/x/crosschain/client/integrationtests/cli_test.go @@ -1,6 +1,3 @@ -//go:build TESTNET -// +build TESTNET - package integrationtests import ( diff --git a/x/crosschain/client/integrationtests/inbound_voter_test.go b/x/crosschain/client/integrationtests/inbound_voter_test.go index 6305295b2a..cd01d95381 100644 --- a/x/crosschain/client/integrationtests/inbound_voter_test.go +++ b/x/crosschain/client/integrationtests/inbound_voter_test.go @@ -1,19 +1,117 @@ -//go:build TESTNET -// +build TESTNET - package integrationtests import ( + "encoding/json" + "fmt" + "strings" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - crosschainCli "github.com/zeta-chain/zetacore/x/crosschain/client/cli" + crosschaincli "github.com/zeta-chain/zetacore/x/crosschain/client/cli" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" - observerCli "github.com/zeta-chain/zetacore/x/observer/client/cli" + observercli "github.com/zeta-chain/zetacore/x/observer/client/cli" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" ) +type messageLog struct { + Events []event `json:"events"` +} + +type event struct { + Type string `json:"type"` + Attributes []attribute `json:"attributes"` +} + +type attribute struct { + Key string `json:"key"` + Value string `json:"value"` +} + +// fetchAttribute fetches the attribute from the tx response +func fetchAttribute(rawLog string, key string) (string, error) { + var logs []messageLog + err := json.Unmarshal([]byte(rawLog), &logs) + if err != nil { + return "", err + } + + var attributes []string + for _, log := range logs { + for _, event := range log.Events { + for _, attr := range event.Attributes { + attributes = append(attributes, attr.Key) + if strings.EqualFold(attr.Key, key) { + address := attr.Value + + // trim the quotes + address = address[1 : len(address)-1] + + return address, nil + } + + } + } + } + + return "", fmt.Errorf("attribute %s not found, attributes: %+v", key, attributes) +} + +type txRes struct { + RawLog string `json:"raw_log"` +} + +func ExtractRawLog(str string) (string, error) { + var data txRes + + err := json.Unmarshal([]byte(str), &data) + if err != nil { + return "", err + } + + return data.RawLog, nil +} + func (s *IntegrationTestSuite) TestCCTXInboundVoter() { + broadcaster := s.network.Validators[0] + + var systemContractAddr string + // Initialize system contract + { + out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetAccountCmd(), []string{broadcaster.Address.String(), "--output", "json"}) + s.Require().NoError(err) + var account authtypes.AccountI + s.NoError(broadcaster.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &account)) + signedTx := BuildSignedDeploySystemContract(s.T(), broadcaster, s.cfg.BondDenom, account) + res, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetBroadcastCommand(), []string{signedTx.Name(), "--broadcast-mode", "block"}) + s.Require().NoError(err) + + rawLog, err := ExtractRawLog(res.String()) + s.Require().NoError(err) + + systemContractAddr, err = fetchAttribute(rawLog, "system_contract") + s.Require().NoError(err) + + // update system contract + out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetAccountCmd(), []string{broadcaster.Address.String(), "--output", "json"}) + s.Require().NoError(err) + s.NoError(broadcaster.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &account)) + signedTx = BuildSignedUpdateSystemContract(s.T(), broadcaster, s.cfg.BondDenom, account, systemContractAddr) + res, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetBroadcastCommand(), []string{signedTx.Name(), "--broadcast-mode", "block"}) + s.Require().NoError(err) + } + + // Deploy ETH ZRC20 + { + out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetAccountCmd(), []string{broadcaster.Address.String(), "--output", "json"}) + s.Require().NoError(err) + var account authtypes.AccountI + s.NoError(broadcaster.ClientCtx.Codec.UnmarshalInterfaceJSON(out.Bytes(), &account)) + signedTx := BuildSignedDeployETHZRC20(s.T(), broadcaster, s.cfg.BondDenom, account) + _, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetBroadcastCommand(), []string{signedTx.Name(), "--broadcast-mode", "block"}) + s.Require().NoError(err) + } + tt := []struct { name string votes map[string]observerTypes.VoteType @@ -128,8 +226,6 @@ func (s *IntegrationTestSuite) TestCCTXInboundVoter() { for _, test := range tt { test := test s.Run(test.name, func() { - broadcaster := s.network.Validators[0] - // Vote the gas price for _, val := range s.network.Validators { out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetAccountCmd(), []string{val.Address.String(), "--output", "json"}) @@ -178,7 +274,7 @@ func (s *IntegrationTestSuite) TestCCTXInboundVoter() { // Get the ballot ballotIdentifier := GetBallotIdentifier(test.name) - out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observerCli.CmdBallotByIdentifier(), []string{ballotIdentifier, "--output", "json"}) + out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observercli.CmdBallotByIdentifier(), []string{ballotIdentifier, "--output", "json"}) s.Require().NoError(err) ballot := observerTypes.QueryBallotByIdentifierResponse{} s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &ballot)) @@ -187,25 +283,25 @@ func (s *IntegrationTestSuite) TestCCTXInboundVoter() { s.Assert().Equal(len(test.votes), len(ballot.Voters)) for _, vote := range ballot.Voters { if test.votes[vote.VoterAddress] == observerTypes.VoteType_FailureObservation { - s.Assert().Equal(observerTypes.VoteType_NotYetVoted, vote.VoteType) + s.Assert().Equal(observerTypes.VoteType_NotYetVoted.String(), vote.VoteType.String()) continue } - s.Assert().Equal(test.votes[vote.VoterAddress], vote.VoteType) + s.Assert().Equal(test.votes[vote.VoterAddress].String(), vote.VoteType.String()) } - s.Assert().Equal(test.ballotResult, ballot.BallotStatus) + s.Assert().Equal(test.ballotResult.String(), ballot.BallotStatus.String()) // Get the cctx and check its status cctxIdentifier := ballotIdentifier if test.falseBallotIdentifier != "" { cctxIdentifier = test.falseBallotIdentifier } - out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschainCli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) + out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschaincli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) cctx := crosschaintypes.QueryGetCctxResponse{} if test.cctxStatus == crosschaintypes.CctxStatus_PendingRevert { s.Require().Contains(out.String(), "not found") } else { s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &cctx)) - s.Assert().Equal(test.cctxStatus, cctx.CrossChainTx.CctxStatus.Status) + s.Assert().Equal(test.cctxStatus.String(), cctx.CrossChainTx.CctxStatus.Status.String(), cctx.CrossChainTx.CctxStatus.StatusMessage) } }) } diff --git a/x/crosschain/client/integrationtests/outbound_voter_test.go b/x/crosschain/client/integrationtests/outbound_voter_test.go index 92237b62b9..cb36954838 100644 --- a/x/crosschain/client/integrationtests/outbound_voter_test.go +++ b/x/crosschain/client/integrationtests/outbound_voter_test.go @@ -1,15 +1,12 @@ -//go:build TESTNET -// +build TESTNET - package integrationtests import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - crosschainCli "github.com/zeta-chain/zetacore/x/crosschain/client/cli" + crosschaincli "github.com/zeta-chain/zetacore/x/crosschain/client/cli" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" - observerCli "github.com/zeta-chain/zetacore/x/observer/client/cli" + observercli "github.com/zeta-chain/zetacore/x/observer/client/cli" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -79,7 +76,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() { }, correctBallotResult: observerTypes.BallotStatus_BallotInProgress, cctxStatus: crosschaintypes.CctxStatus_PendingOutbound, - valueReceived: "7993442360774956232", + valueReceived: "7990439496224753106", }, { name: "Fake ballot has more votes outbound gets finalized", @@ -159,10 +156,10 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() { // Get the ballot cctxIdentifier := GetBallotIdentifier(test.name) - out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschainCli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) + out, err := clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschaincli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) cctx := crosschaintypes.QueryGetCctxResponse{} s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &cctx)) - s.Assert().Equal(crosschaintypes.CctxStatus_PendingOutbound, cctx.CrossChainTx.CctxStatus.Status) + s.Assert().Equal(crosschaintypes.CctxStatus_PendingOutbound.String(), cctx.CrossChainTx.CctxStatus.Status.String(), cctx.CrossChainTx.CctxStatus.StatusMessage) nonce := cctx.CrossChainTx.GetCurrentOutTxParam().OutboundTxTssNonce // Check the vote in the ballot and vote the outbound tx fakeVotes := []string{} @@ -201,27 +198,27 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() { s.Require().NoError(s.network.WaitForNBlocks(2)) // Get the cctx - out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschainCli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) + out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, crosschaincli.CmdShowSend(), []string{cctxIdentifier, "--output", "json"}) cctx = crosschaintypes.QueryGetCctxResponse{} s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &cctx)) - s.Assert().Equal(test.cctxStatus, cctx.CrossChainTx.CctxStatus.Status) + s.Assert().Equal(test.cctxStatus.String(), cctx.CrossChainTx.CctxStatus.Status.String(), cctx.CrossChainTx.CctxStatus.StatusMessage) outboundBallotIdentifier := GetBallotIdentifierOutBound(nonce, cctxIdentifier, test.name, test.valueReceived) - out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observerCli.CmdBallotByIdentifier(), []string{outboundBallotIdentifier, "--output", "json"}) + out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observercli.CmdBallotByIdentifier(), []string{outboundBallotIdentifier, "--output", "json"}) s.Require().NoError(err) ballot := observerTypes.QueryBallotByIdentifierResponse{} s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &ballot)) // Check the votes - s.Require().Equal(test.correctBallotResult, ballot.BallotStatus) + s.Require().Equal(test.correctBallotResult.String(), ballot.BallotStatus.String()) for _, vote := range test.votes { for _, ballotvote := range ballot.Voters { if vote.voterAddress == ballotvote.VoterAddress { if !vote.isFakeVote { - s.Assert().Equal(vote.voteType, ballotvote.VoteType) + s.Assert().Equal(vote.voteType.String(), ballotvote.VoteType.String()) } else { - s.Assert().Equal(observerTypes.VoteType_NotYetVoted, ballotvote.VoteType) + s.Assert().Equal(observerTypes.VoteType_NotYetVoted.String(), ballotvote.VoteType.String()) } break } @@ -229,7 +226,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() { } if len(fakeVotes) > 0 { outboundFakeBallotIdentifier := GetBallotIdentifierOutBound(nonce, cctxIdentifier, test.name+"falseVote", test.valueReceived) - out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observerCli.CmdBallotByIdentifier(), []string{outboundFakeBallotIdentifier, "--output", "json"}) + out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observercli.CmdBallotByIdentifier(), []string{outboundFakeBallotIdentifier, "--output", "json"}) s.Require().NoError(err) fakeBallot := observerTypes.QueryBallotByIdentifierResponse{} s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &fakeBallot)) @@ -237,7 +234,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() { if vote.isFakeVote { for _, ballotVote := range fakeBallot.Voters { if vote.voterAddress == ballotVote.VoterAddress { - s.Assert().Equal(vote.voteType, ballotVote.VoteType) + s.Assert().Equal(vote.voteType.String(), ballotVote.VoteType.String()) break } } diff --git a/x/crosschain/client/integrationtests/suite.go b/x/crosschain/client/integrationtests/suite.go index 8b8db1b25f..c64dcd7644 100644 --- a/x/crosschain/client/integrationtests/suite.go +++ b/x/crosschain/client/integrationtests/suite.go @@ -1,6 +1,3 @@ -//go:build TESTNET -// +build TESTNET - package integrationtests import ( @@ -59,7 +56,6 @@ func (s *IntegrationTestSuite) SetupSuite() { time.Sleep(3 * time.Second) _, err = s.network.WaitForHeight(1) s.Require().NoError(err) - } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 9391f7c485..c33adc8420 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -66,9 +66,7 @@ func (k Keeper) HandleEVMDeposit( msg.CoinType, msg.Asset, ) - if fungibletypes.IsContractReverted(evmTxResponse, err) || - errors.Is(err, fungibletypes.ErrForeignCoinCapReached) || - errors.Is(err, fungibletypes.ErrCallNonContract) { + if fungibletypes.IsContractReverted(evmTxResponse, err) || errShouldRevertCctx(err) { return true, err } else if err != nil { return false, err @@ -105,6 +103,14 @@ func (k Keeper) HandleEVMDeposit( return false, nil } +// errShouldRevertCctx returns true if the cctx should revert from the error of the deposit +// we revert the cctx if a non-contract is tried to be called, if the liquidity cap is reached, or if the zrc20 is paused +func errShouldRevertCctx(err error) bool { + return errors.Is(err, fungibletypes.ErrForeignCoinCapReached) || + errors.Is(err, fungibletypes.ErrCallNonContract) || + errors.Is(err, fungibletypes.ErrPausedZRC20) +} + // parseAddressAndData parses the message string into an address and data // message is hex encoded byte array // [ contractAddress calldata ] diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index 0a0626af5d..65483d89c1 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -253,6 +253,50 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { fungibleMock.AssertExpectations(t) }) + t.Run("should return error with reverted if deposit ERC20 fails with zrc20 paused", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseFungibleMock: true, + }) + + senderChain := getValidEthChain(t) + + fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) + receiver := sample.EthAddress() + amount := big.NewInt(42) + + // expect DepositCoinZeta to be called + // ZRC20DepositAndCallContract(ctx, from, to, msg.Amount.BigInt(), senderChain, msg.Message, contract, data, msg.CoinType, msg.Asset) + fungibleMock.On( + "ZRC20DepositAndCallContract", + ctx, + mock.Anything, + receiver, + amount, + senderChain, + mock.Anything, + common.CoinType_ERC20, + mock.Anything, + ).Return(&evmtypes.MsgEthereumTxResponse{}, false, fungibletypes.ErrPausedZRC20) + + // call HandleEVMDeposit + reverted, err := k.HandleEVMDeposit( + ctx, + sample.CrossChainTx(t, "foo"), + types.MsgVoteOnObservedInboundTx{ + Sender: sample.EthAddress().String(), + Receiver: receiver.String(), + Amount: math.NewUintFromBigInt(amount), + CoinType: common.CoinType_ERC20, + Message: "", + Asset: "", + }, + senderChain, + ) + require.ErrorIs(t, err, fungibletypes.ErrPausedZRC20) + require.True(t, reverted) + fungibleMock.AssertExpectations(t) + }) + t.Run("should return error with reverted if deposit ERC20 fails with calling a non-contract address", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseFungibleMock: true, diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index c575598cf1..3a1c40c0ee 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -124,7 +124,10 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W } receiverChain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(foreignCoin.ForeignChainId) - senderChain := common.ZetaChain() + senderChain, err := common.ZetaChainFromChainID(ctx.ChainID()) + if err != nil { + return fmt.Errorf("ProcessZRC20WithdrawalEvent: failed to convert chainID: %s", err.Error()) + } toAddr, err := receiverChain.EncodeAddress(event.To) if err != nil { return fmt.Errorf("cannot encode address %s: %s", event.To, err.Error()) @@ -147,9 +150,10 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W "", event.Raw.TxHash.String(), event.Raw.BlockNumber, - gasLimit.Uint64()+uint64(event.Raw.Index), + gasLimit.Uint64(), foreignCoin.CoinType, foreignCoin.Asset, + event.Raw.Index, ) sendHash := msg.Digest() @@ -206,7 +210,10 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return types.ErrUnableToSendCoinType } toAddr := "0x" + hex.EncodeToString(event.DestinationAddress) - senderChain := common.ZetaChain() + senderChain, err := common.ZetaChainFromChainID(ctx.ChainID()) + if err != nil { + return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error()) + } amount := math.NewUintFromBigInt(event.ZetaValueAndGas) // Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs. @@ -220,9 +227,10 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC "", event.Raw.TxHash.String(), event.Raw.BlockNumber, - 90000+uint64(event.Raw.Index), + 90000, common.CoinType_Zeta, "", + event.Raw.Index, ) sendHash := msg.Digest() diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index a370c7a672..bc7ac00feb 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -271,7 +271,7 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( gasZRC20, err := k.fungibleKeeper.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) if err != nil { - return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to get system contract gas coin") + return cosmoserrors.Wrapf(err, "PayGasInZetaAndUpdateCctx: unable to get system contract gas coin, chaind ID %d", chainID) } // get the gas price diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index a1ad790d4a..73fdebdde3 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -28,13 +28,9 @@ func getValidEthChainID(t *testing.T) int64 { } // get a valid eth chain independently of the build flag -func getValidEthChain(t *testing.T) *zetacommon.Chain { - list := zetacommon.DefaultChainsList() - require.True(t, len(list) > 1) - require.NotNil(t, list[1]) - require.False(t, zetacommon.IsBitcoinChain(list[1].ChainId)) - - return list[1] +func getValidEthChain(_ *testing.T) *zetacommon.Chain { + goerli := zetacommon.GoerliLocalnetChain() + return &goerli } // assert that a contract has been deployed by checking stored code is non-empty. @@ -250,7 +246,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -308,7 +304,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -348,7 +344,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -413,7 +409,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -476,7 +472,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -521,7 +517,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -576,7 +572,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -637,7 +633,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: zetacommon.ZetaChain().ChainId, + ReceiverChainId: zetacommon.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, diff --git a/x/crosschain/keeper/grpc_query_get_tss_address.go b/x/crosschain/keeper/grpc_query_get_tss_address.go index 6d21719388..1670d2d9d2 100644 --- a/x/crosschain/keeper/grpc_query_get_tss_address.go +++ b/x/crosschain/keeper/grpc_query_get_tss_address.go @@ -3,13 +3,8 @@ package keeper import ( "context" - "github.com/btcsuite/btcutil" - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - zcommon "github.com/zeta-chain/zetacore/common/cosmos" - "github.com/zeta-chain/zetacore/zetaclient/config" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -37,11 +32,20 @@ func (k Keeper) GetTssAddress(goCtx context.Context, req *types.QueryGetTssAddre } } } - ethAddress, err := getTssAddrEVM(tssPubKey) + ethAddress, err := common.GetTssAddrEVM(tssPubKey) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - btcAddress, err := getTssAddrBTC(tssPubKey) + + bitcoinParams := common.BitcoinRegnetParams + if req.BitcoinChainId != 0 { + bitcoinParams, err = common.BitcoinNetParamsFromChainID(req.BitcoinChainId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + } + + btcAddress, err := common.GetTssAddrBTC(tssPubKey, bitcoinParams) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -51,42 +55,3 @@ func (k Keeper) GetTssAddress(goCtx context.Context, req *types.QueryGetTssAddre Btc: btcAddress, }, nil } - -func getTssAddrEVM(tssPubkey string) (ethcommon.Address, error) { - var keyAddr ethcommon.Address - pubk, err := zcommon.GetPubKeyFromBech32(zcommon.Bech32PubKeyTypeAccPub, tssPubkey) - if err != nil { - return keyAddr, err - } - //keyAddrBytes := pubk.EVMAddress().Bytes() - pubk.Bytes() - decompresspubkey, err := crypto.DecompressPubkey(pubk.Bytes()) - if err != nil { - return keyAddr, err - } - - keyAddr = crypto.PubkeyToAddress(*decompresspubkey) - - return keyAddr, nil -} - -func getTssAddrBTC(tssPubkey string) (string, error) { - addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tssPubkey) - if err != nil { - return "", err - } - - return addrWPKH.EncodeAddress(), nil -} - -func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string) (*btcutil.AddressWitnessPubKeyHash, error) { - pubk, err := zcommon.GetPubKeyFromBech32(zcommon.Bech32PubKeyTypeAccPub, tssPubkey) - if err != nil { - return nil, err - } - addr, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(pubk.Bytes()), config.BitconNetParams) - if err != nil { - return nil, err - } - return addr, nil -} diff --git a/x/crosschain/keeper/keeper_cross_chain_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx.go index 3ceb63ada5..55da65fb9d 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx.go @@ -127,6 +127,29 @@ func (k Keeper) CctxAll(c context.Context, req *types.QueryAllCctxRequest) (*typ return &types.QueryAllCctxResponse{CrossChainTx: sends, Pagination: pageRes}, nil } +func (k Keeper) CctxByStatus(c context.Context, req *types.QueryCctxByStatusRequest) (*types.QueryCctxByStatusResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + p := types.KeyPrefix(fmt.Sprintf("%s", types.SendKey)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), p) + + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + cctxList := make([]types.CrossChainTx, 0) + for ; iterator.Valid(); iterator.Next() { + var val types.CrossChainTx + k.cdc.MustUnmarshal(iterator.Value(), &val) + if val.CctxStatus.Status == req.Status { + cctxList = append(cctxList, val) + } + } + + return &types.QueryCctxByStatusResponse{CrossChainTx: cctxList}, nil +} + func (k Keeper) Cctx(c context.Context, req *types.QueryGetCctxRequest) (*types.QueryGetCctxResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go index d4454ba42f..cc92630dca 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go @@ -177,11 +177,7 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg if err != nil { return err } - err = k.UpdateNonce(tmpCtx, chain.ChainId, &cctx) - if err != nil { - return err - } - return nil + return k.UpdateNonce(tmpCtx, chain.ChainId, &cctx) }() if err != nil { // do not commit anything here as the CCTX should be aborted @@ -200,45 +196,41 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg } } - cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()) + cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()+" deposit revert message: "+revertMessage) return &types.MsgVoteOnObservedInboundTxResponse{}, nil } commit() cctx.CctxStatus.ChangeStatus(types.CctxStatus_PendingRevert, revertMessage) return &types.MsgVoteOnObservedInboundTxResponse{}, nil - } else { // successful HandleEVMDeposit; - commit() - cctx.CctxStatus.ChangeStatus(types.CctxStatus_OutboundMined, "Remote omnichain contract call completed") - return &types.MsgVoteOnObservedInboundTxResponse{}, nil } - } else { // Cross Chain SWAP - tmpCtx, commit := ctx.CacheContext() - err = func() error { - err := k.PayGasAndUpdateCctx( - tmpCtx, - receiverChain.ChainId, - &cctx, - cctx.InboundTxParams.Amount, - false, - ) - if err != nil { - return err - } - err = k.UpdateNonce(tmpCtx, receiverChain.ChainId, &cctx) - if err != nil { - return err - } - return nil - }() + // successful HandleEVMDeposit; + commit() + cctx.CctxStatus.ChangeStatus(types.CctxStatus_OutboundMined, "Remote omnichain contract call completed") + return &types.MsgVoteOnObservedInboundTxResponse{}, nil + } + + // Receiver is not ZetaChain: Cross Chain SWAP + tmpCtx, commit := ctx.CacheContext() + err = func() error { + err := k.PayGasAndUpdateCctx( + tmpCtx, + receiverChain.ChainId, + &cctx, + cctx.InboundTxParams.Amount, + false, + ) if err != nil { - // do not commit anything here as the CCTX should be aborted - cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()) - return &types.MsgVoteOnObservedInboundTxResponse{}, nil + return err } - commit() - cctx.CctxStatus.ChangeStatus(types.CctxStatus_PendingOutbound, "") - k.RemoveInTxTrackerIfExists(ctx, cctx.InboundTxParams.SenderChainId, cctx.InboundTxParams.InboundTxObservedHash) + return k.UpdateNonce(tmpCtx, receiverChain.ChainId, &cctx) + }() + if err != nil { + // do not commit anything here as the CCTX should be aborted + cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()) return &types.MsgVoteOnObservedInboundTxResponse{}, nil } + commit() + cctx.CctxStatus.ChangeStatus(types.CctxStatus_PendingOutbound, "") + return &types.MsgVoteOnObservedInboundTxResponse{}, nil } diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go index 31cf4bfcb1..8141888459 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go @@ -107,8 +107,8 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms return nil, err } - ballot, isFinalized := k.zetaObserverKeeper.CheckIfFinalizingVote(ctx, ballot) - if !isFinalized { + ballot, isFinalizedInThisBlock := k.zetaObserverKeeper.CheckIfFinalizingVote(ctx, ballot) + if !isFinalizedInThisBlock { // Return nil here to add vote to ballot and commit state return &types.MsgVoteOnObservedOutboundTxResponse{}, nil } @@ -155,7 +155,7 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms newStatus := cctx.CctxStatus.Status.String() EmitOutboundSuccess(tmpCtx, msg, oldStatus.String(), newStatus, cctx) case observerTypes.BallotStatus_BallotFinalized_FailureObservation: - if msg.CoinType == common.CoinType_Cmd || cctx.InboundTxParams.SenderChainId == common.ZetaChain().ChainId { + if msg.CoinType == common.CoinType_Cmd || common.IsZetaChain(cctx.InboundTxParams.SenderChainId) { // if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, "") } else { @@ -221,6 +221,7 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms // #nosec G701 always in range k.RemoveFromPendingNonces(ctx, tss.TssPubkey, msg.OutTxChain, int64(msg.OutTxTssNonce)) k.RemoveOutTxTracker(ctx, msg.OutTxChain, msg.OutTxTssNonce) + ctx.Logger().Info(fmt.Sprintf("Remove tracker %s: , Block Height : %d ", getOutTrackerIndex(msg.OutTxChain, msg.OutTxTssNonce), ctx.BlockHeight())) k.SetCctxAndNonceToCctxAndInTxHashToCctx(ctx, cctx) return &types.MsgVoteOnObservedOutboundTxResponse{}, nil } diff --git a/x/crosschain/keeper/msg_migrate_tss_funds.go b/x/crosschain/keeper/msg_migrate_tss_funds.go index 85107860dc..bd7ae51004 100644 --- a/x/crosschain/keeper/msg_migrate_tss_funds.go +++ b/x/crosschain/keeper/msg_migrate_tss_funds.go @@ -48,28 +48,14 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s if len(tssList) < 2 { return errorsmod.Wrap(types.ErrCannotMigrateTss, "only one TSS found") } + // Sort tssList by FinalizedZetaHeight sort.SliceStable(tssList, func(i, j int) bool { return tssList[i].FinalizedZetaHeight < tssList[j].FinalizedZetaHeight }) + // Always migrate to the latest TSS if multiple TSS addresses have been generated newTss := tssList[len(tssList)-1] - ethAddressOld, err := getTssAddrEVM(currentTss.TssPubkey) - if err != nil { - return err - } - btcAddressOld, err := getTssAddrBTC(currentTss.TssPubkey) - if err != nil { - return err - } - ethAddressNew, err := getTssAddrEVM(newTss.TssPubkey) - if err != nil { - return err - } - btcAddressNew, err := getTssAddrBTC(newTss.TssPubkey) - if err != nil { - return err - } medianGasPrice, isFound := k.GetMedianGasPriceInUint(ctx, chainID) if !isFound { @@ -119,22 +105,49 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s TssPubkey: currentTss.TssPubkey, }}} + // Set the sender and receiver addresses for EVM chain if common.IsEVMChain(chainID) { + ethAddressOld, err := common.GetTssAddrEVM(currentTss.TssPubkey) + if err != nil { + return err + } + ethAddressNew, err := common.GetTssAddrEVM(newTss.TssPubkey) + if err != nil { + return err + } cctx.InboundTxParams.Sender = ethAddressOld.String() cctx.GetCurrentOutTxParam().Receiver = ethAddressNew.String() } + + // Set the sender and receiver addresses for Bitcoin chain if common.IsBitcoinChain(chainID) { + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(chainID) + if err != nil { + return err + } + btcAddressOld, err := common.GetTssAddrBTC(currentTss.TssPubkey, bitcoinNetParams) + if err != nil { + return err + } + btcAddressNew, err := common.GetTssAddrBTC(newTss.TssPubkey, bitcoinNetParams) + if err != nil { + return err + } cctx.InboundTxParams.Sender = btcAddressOld cctx.GetCurrentOutTxParam().Receiver = btcAddressNew } + if cctx.GetCurrentOutTxParam().Receiver == "" { return errorsmod.Wrap(types.ErrCannotMigrateTss, fmt.Sprintf("chain %d is not supported", chainID)) } - err = k.UpdateNonce(ctx, chainID, &cctx) + + err := k.UpdateNonce(ctx, chainID, &cctx) if err != nil { return err } + k.SetCctxAndNonceToCctxAndInTxHashToCctx(ctx, cctx) EmitEventInboundFinalized(ctx, &cctx) + return nil } diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 715635e9fe..d4102e0b17 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -1,6 +1,3 @@ -//go:build TESTNET -// +build TESTNET - package keeper_test import ( @@ -14,7 +11,7 @@ import ( "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" - observerTypes "github.com/zeta-chain/zetacore/x/observer/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) func TestMsgServer_AddToInTxTracker(t *testing.T) { @@ -41,7 +38,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { t.Run("fail to add proof based tracker with wrong tx hash", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getValidEthChainID(t) txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -55,14 +52,14 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: block.Hash().Hex(), TxIndex: txIndex, }) - require.ErrorIs(t, types.ErrTxBodyVerificationFail, err) + require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) require.False(t, found) }) t.Run("fail to add proof based tracker with wrong chain id", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getValidEthChainID(t) txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -76,14 +73,14 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: block.Hash().Hex(), TxIndex: txIndex, }) - require.ErrorIs(t, types.ErrTxBodyVerificationFail, err) + require.ErrorIs(t, err, observertypes.ErrSupportedChains) _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) require.False(t, found) }) t.Run("fail normal user submit without proof", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) tx_hash := "string" - chainID := int64(5) + chainID := getValidEthChainID(t) msgServer := keeper.NewMsgServerImpl(*k) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), @@ -94,7 +91,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { BlockHash: "", TxIndex: 0, }) - require.ErrorIs(t, observerTypes.ErrNotAuthorized, err) + require.ErrorIs(t, err, observertypes.ErrNotAuthorized) _, found := k.GetInTxTracker(ctx, chainID, tx_hash) require.False(t, found) }) @@ -103,7 +100,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { admin := sample.AccAddress() setAdminPolicies(ctx, zk, admin) tx_hash := "string" - chainID := int64(5) + chainID := getValidEthChainID(t) msgServer := keeper.NewMsgServerImpl(*k) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, @@ -123,7 +120,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { admin := sample.AccAddress() setAdminPolicies(ctx, zk, admin) tx_hash := "string" - chainID := int64(5) + chainID := getValidEthChainID(t) msgServer := keeper.NewMsgServerImpl(*k) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, @@ -144,7 +141,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_index int64, chainID int64, header ethtypes.Header, headerRLP []byte, block *ethtypes.Block) { params := zk.ObserverKeeper.GetParams(ctx) - params.ObserverParams = append(params.ObserverParams, &observerTypes.ObserverParams{ + params.ObserverParams = append(params.ObserverParams, &observertypes.ObserverParams{ Chain: &common.Chain{ ChainId: chainID, ChainName: common.ChainName_goerli_testnet, @@ -161,14 +158,14 @@ func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_inde ChainId: chainID, Header: common.NewEthereumHeader(headerRLP), }) - zk.ObserverKeeper.SetCoreParams(ctx, observerTypes.CoreParamsList{CoreParams: []*observerTypes.CoreParams{ + zk.ObserverKeeper.SetCoreParams(ctx, observertypes.CoreParamsList{CoreParams: []*observertypes.CoreParams{ { ChainId: chainID, ConnectorContractAddress: block.Transactions()[tx_index].To().Hex(), }, }}) - zk.ObserverKeeper.SetCrosschainFlags(ctx, observerTypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observerTypes.BlockHeaderVerificationFlags{ + zk.ObserverKeeper.SetCrosschainFlags(ctx, observertypes.CrosschainFlags{ + BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: false, }, diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go index 3c77f829b6..7677e4a7b8 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go @@ -15,7 +15,6 @@ import ( "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" - "github.com/zeta-chain/zetacore/zetaclient/config" ) // AddToOutTxTracker adds a new record to the outbound transaction tracker. @@ -76,6 +75,7 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO Nonce: msg.Nonce, HashList: []*types.TxHashList{&hash}, }) + ctx.Logger().Info(fmt.Sprintf("Add tracker %s: , Block Height : %d ", getOutTrackerIndex(chain.ChainId, msg.Nonce), ctx.BlockHeight())) return &types.MsgAddToOutTxTrackerResponse{}, nil } @@ -107,7 +107,13 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO func (k Keeper) VerifyOutTxBody(ctx sdk.Context, msg *types.MsgAddToOutTxTracker, txBytes []byte) error { // get tss address - tss, err := k.GetTssAddress(ctx, &types.QueryGetTssAddressRequest{}) + var bitcoinChainID int64 + if common.IsBitcoinChain(msg.ChainId) { + bitcoinChainID = msg.ChainId + } + tss, err := k.GetTssAddress(ctx, &types.QueryGetTssAddressRequest{ + BitcoinChainId: bitcoinChainID, + }) if err != nil { return err } @@ -158,6 +164,9 @@ func VerifyEVMOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssEth // VerifyBTCOutTxBody validates the SegWit sender address, nonce and chain id and tx hash // Note: 'msg' may contain fabricated information func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc string) error { + if !common.IsBitcoinChain(msg.ChainId) { + return fmt.Errorf("not a Bitcoin chain ID %d", msg.ChainId) + } tx, err := btcutil.NewTxFromBytes(txBytes) if err != nil { return err @@ -170,7 +179,14 @@ func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc if err != nil { return fmt.Errorf("failed to parse public key") } - addrP2WPKH, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(pubKey.SerializeCompressed()), config.BitconNetParams) + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(msg.ChainId) + if err != nil { + return fmt.Errorf("failed to get Bitcoin net params, error %s", err.Error()) + } + addrP2WPKH, err := btcutil.NewAddressWitnessPubKeyHash( + btcutil.Hash160(pubKey.SerializeCompressed()), + bitcoinNetParams, + ) if err != nil { return fmt.Errorf("failed to create P2WPKH address") } @@ -178,9 +194,6 @@ func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc return fmt.Errorf("sender %s is not tss address", addrP2WPKH.EncodeAddress()) } } - if common.BtcChainID() != msg.ChainId { - return fmt.Errorf("want btc chain id %d, got %d", common.BtcChainID(), msg.ChainId) - } if len(tx.MsgTx().TxOut) < 1 { return fmt.Errorf("outTx should have at least one output") } diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go index 2751a62c1d..aec27fe1da 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go @@ -1,12 +1,10 @@ -//go:build TESTNET -// +build TESTNET - package keeper_test import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/common/ethereum" @@ -14,14 +12,19 @@ import ( "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) +func getEthereumChainID() int64 { + return 5 // Goerli + +} func TestMsgServer_AddToOutTxTracker(t *testing.T) { t.Run("add tracker admin", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) admin := sample.AccAddress() setAdminPolicies(ctx, zk, admin) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, _, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -40,10 +43,50 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { _, found := k.GetOutTxTracker(ctx, chainID, 0) require.True(t, found) }) + t.Run("unable to add tracker admin exceeding maximum allowed length of hashlist without proof", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + setAdminPolicies(ctx, zk, admin) + chainID := getEthereumChainID() + txIndex, block, header, headerRLP, _, tx, err := sample.Proof() + require.NoError(t, err) + setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + setupTssAndNonceToCctx(k, ctx, chainID, 0) + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: 0, + HashList: []*types.TxHashList{ + { + TxHash: "hash1", + TxSigner: sample.AccAddress(), + Proved: false, + }, + { + TxHash: "hash2", + TxSigner: sample.AccAddress(), + Proved: false, + }, + }, + }) + msgServer := keeper.NewMsgServerImpl(*k) + _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: tx.Hash().Hex(), + Proof: nil, + BlockHash: "", + TxIndex: 0, + Nonce: 0, + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, 0) + require.True(t, found) + require.Equal(t, 2, len(tracker.HashList)) + }) t.Run("fail add proof based tracker with wrong chainID", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -58,14 +101,14 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, types.ErrTxBodyVerificationFail, err) + require.ErrorIs(t, err, observertypes.ErrSupportedChains) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) require.False(t, found) }) t.Run("fail add proof based tracker with wrong nonce", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -80,14 +123,14 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: 1, }) - require.ErrorIs(t, types.ErrTxBodyVerificationFail, err) + require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, 1) require.False(t, found) }) t.Run("fail add proof based tracker with wrong tx_hash", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -102,14 +145,14 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, types.ErrTxBodyVerificationFail, err) + require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) require.False(t, found) }) t.Run("fail proof based tracker with incorrect proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, _, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -124,13 +167,13 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: txIndex, Nonce: tx.Nonce(), }) - require.ErrorIs(t, types.ErrProofVerificationFail, err) + require.ErrorIs(t, err, types.ErrProofVerificationFail) _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) require.False(t, found) }) t.Run("add proof based tracker with correct proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := int64(5) + chainID := getEthereumChainID() txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() require.NoError(t, err) setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) @@ -149,11 +192,98 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) require.True(t, found) }) + t.Run("add proven txHash even if length of hashList is already 2", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + chainID := getEthereumChainID() + txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + require.NoError(t, err) + setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: tx.Nonce(), + HashList: []*types.TxHashList{ + { + TxHash: "hash1", + TxSigner: sample.AccAddress(), + Proved: false, + }, + { + TxHash: "hash2", + TxSigner: sample.AccAddress(), + Proved: false, + }, + }, + }) + msgServer := keeper.NewMsgServerImpl(*k) + _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: sample.AccAddress(), + ChainId: chainID, + TxHash: tx.Hash().Hex(), + Proof: proof, + BlockHash: block.Hash().Hex(), + TxIndex: txIndex, + Nonce: tx.Nonce(), + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + require.True(t, found) + require.Equal(t, 3, len(tracker.HashList)) + // Proven tracker is prepended to the list + require.True(t, tracker.HashList[0].Proved) + require.False(t, tracker.HashList[1].Proved) + require.False(t, tracker.HashList[2].Proved) + }) + t.Run("add proof for existing txHash", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + chainID := getEthereumChainID() + txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + require.NoError(t, err) + setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: tx.Nonce(), + HashList: []*types.TxHashList{ + { + TxHash: tx.Hash().Hex(), + TxSigner: sample.AccAddress(), + Proved: false, + }, + }, + }) + tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + assert.True(t, found) + require.False(t, tracker.HashList[0].Proved) + msgServer := keeper.NewMsgServerImpl(*k) + _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: sample.AccAddress(), + ChainId: chainID, + TxHash: tx.Hash().Hex(), + Proof: proof, + BlockHash: block.Hash().Hex(), + TxIndex: txIndex, + Nonce: tx.Nonce(), + }) + require.NoError(t, err) + tracker, found = k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + require.True(t, found) + require.Equal(t, 1, len(tracker.HashList)) + require.True(t, tracker.HashList[0].Proved) + }) } func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce int64) { + + tssPubKey := "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p" k.SetTSS(ctx, types.TSS{ - TssPubkey: "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p", + TssPubkey: tssPubKey, + }) + k.SetPendingNonces(ctx, types.PendingNonces{ + Tss: tssPubKey, + NonceLow: 0, + NonceHigh: 1, + ChainId: chainId, }) cctx := types.CrossChainTx{ Creator: "any", diff --git a/x/crosschain/keeper/test_privnet.go b/x/crosschain/keeper/test_privnet.go deleted file mode 100644 index a9a96a2586..0000000000 --- a/x/crosschain/keeper/test_privnet.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/common" - "github.com/zeta-chain/zetacore/x/crosschain/types" - zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" -) - -func (k Keeper) TestWhitelistERC20(ctx sdk.Context) error { - goCtx := sdk.UnwrapSDKContext(ctx) - creator := k.zetaObserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_group1) - msg := types.NewMsgWhitelistERC20(creator, types.ModuleAddressEVM.Hex(), common.GoerliChain().ChainId, "test", "testerc20", 17, 90_000) - - msgServer := NewMsgServerImpl(k) - _, err := msgServer.WhitelistERC20(goCtx, msg) - if err != nil { - panic(err) - } - return nil -} diff --git a/x/crosschain/keeper/test_testnet.go b/x/crosschain/keeper/test_testnet.go deleted file mode 100644 index 7a3a7375b8..0000000000 --- a/x/crosschain/keeper/test_testnet.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build !PRIVNET -// +build !PRIVNET - -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) TestWhitelistERC20(_ sdk.Context) error { - return nil -} diff --git a/x/crosschain/keeper/verify_proof.go b/x/crosschain/keeper/verify_proof.go index c80a600078..ffc8129c9f 100644 --- a/x/crosschain/keeper/verify_proof.go +++ b/x/crosschain/keeper/verify_proof.go @@ -86,7 +86,9 @@ func (k Keeper) VerifyEVMInTxBody(ctx sdk.Context, msg *types.MsgAddToInTxTracke } return nil case common.CoinType_Gas: - tss, err := k.GetTssAddress(ctx, &types.QueryGetTssAddressRequest{}) + tss, err := k.GetTssAddress(ctx, &types.QueryGetTssAddressRequest{ + BitcoinChainId: msg.ChainId, + }) if err != nil { return err } diff --git a/x/crosschain/module.go b/x/crosschain/module.go index 4be40efde9..0b07eee1d2 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -185,13 +185,6 @@ func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock executes all ABCI BeginBlock logic respective to the crosschain module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { - if ctx.BlockHeight() == 200 { - err := am.keeper.TestWhitelistERC20(ctx) - if err != nil { - panic(err) - } - } - err := am.keeper.IterateAndUpdateCctxGasPrice(ctx) if err != nil { ctx.Logger().Error("Error iterating and updating pending cctx gas price", "err", err.Error()) diff --git a/x/crosschain/types/message_add_to_in_tx_tracker_test.go b/x/crosschain/types/message_add_to_in_tx_tracker_test.go index 0bd45fbb7a..c05272224f 100644 --- a/x/crosschain/types/message_add_to_in_tx_tracker_test.go +++ b/x/crosschain/types/message_add_to_in_tx_tracker_test.go @@ -1,6 +1,3 @@ -//go:build TESTNET -// +build TESTNET - package types_test import ( diff --git a/x/crosschain/types/messages_migrate_tss_funds.go b/x/crosschain/types/message_migrate_tss_funds.go similarity index 100% rename from x/crosschain/types/messages_migrate_tss_funds.go rename to x/crosschain/types/message_migrate_tss_funds.go diff --git a/x/crosschain/types/messages_migrate_tss_funds_test.go b/x/crosschain/types/message_migrate_tss_funds_test.go similarity index 100% rename from x/crosschain/types/messages_migrate_tss_funds_test.go rename to x/crosschain/types/message_migrate_tss_funds_test.go diff --git a/x/crosschain/types/messages_tss_voter.go b/x/crosschain/types/message_tss_voter.go similarity index 100% rename from x/crosschain/types/messages_tss_voter.go rename to x/crosschain/types/message_tss_voter.go diff --git a/x/crosschain/types/messages_update_tss_address.go b/x/crosschain/types/message_update_tss_address.go similarity index 100% rename from x/crosschain/types/messages_update_tss_address.go rename to x/crosschain/types/message_update_tss_address.go diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx.go b/x/crosschain/types/message_vote_on_observed_inbound_tx.go index 12da3a6963..b94b0567a4 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx.go @@ -30,6 +30,7 @@ func NewMsgVoteOnObservedInboundTx( gasLimit uint64, coinType common.CoinType, asset string, + eventIndex uint, ) *MsgVoteOnObservedInboundTx { return &MsgVoteOnObservedInboundTx{ Creator: creator, @@ -45,6 +46,7 @@ func NewMsgVoteOnObservedInboundTx( GasLimit: gasLimit, CoinType: coinType, Asset: asset, + EventIndex: uint64(eventIndex), } } diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go index 9fba3d71bb..777fb6f244 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go @@ -37,6 +37,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, }, { @@ -55,6 +56,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: sdkerrors.ErrInvalidAddress, }, @@ -74,6 +76,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: types.ErrInvalidChainID, }, @@ -93,6 +96,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: types.ErrInvalidChainID, }, @@ -112,6 +116,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: sdkerrors.ErrInvalidRequest, }, @@ -145,6 +150,7 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, } hash := msg.Digest() require.NotEmpty(t, hash, "hash should not be empty") @@ -226,4 +232,10 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { msg2.Asset = sample.StringRandom(r, 32) hash2 = msg2.Digest() require.NotEqual(t, hash, hash2, "asset should change hash") + + // event index used + msg2 = msg + msg2.EventIndex = 43 + hash2 = msg2.Digest() + require.NotEqual(t, hash, hash2, "event index should change hash") } diff --git a/x/crosschain/types/query.pb.go b/x/crosschain/types/query.pb.go index 868abf1169..42d756c744 100644 --- a/x/crosschain/types/query.pb.go +++ b/x/crosschain/types/query.pb.go @@ -31,6 +31,94 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type QueryCctxByStatusRequest struct { + Status CctxStatus `protobuf:"varint,1,opt,name=status,proto3,enum=zetachain.zetacore.crosschain.CctxStatus" json:"status,omitempty"` +} + +func (m *QueryCctxByStatusRequest) Reset() { *m = QueryCctxByStatusRequest{} } +func (m *QueryCctxByStatusRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCctxByStatusRequest) ProtoMessage() {} +func (*QueryCctxByStatusRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{0} +} +func (m *QueryCctxByStatusRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCctxByStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCctxByStatusRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCctxByStatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCctxByStatusRequest.Merge(m, src) +} +func (m *QueryCctxByStatusRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCctxByStatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCctxByStatusRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCctxByStatusRequest proto.InternalMessageInfo + +func (m *QueryCctxByStatusRequest) GetStatus() CctxStatus { + if m != nil { + return m.Status + } + return CctxStatus_PendingInbound +} + +type QueryCctxByStatusResponse struct { + CrossChainTx []CrossChainTx `protobuf:"bytes,1,rep,name=CrossChainTx,proto3" json:"CrossChainTx"` +} + +func (m *QueryCctxByStatusResponse) Reset() { *m = QueryCctxByStatusResponse{} } +func (m *QueryCctxByStatusResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCctxByStatusResponse) ProtoMessage() {} +func (*QueryCctxByStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{1} +} +func (m *QueryCctxByStatusResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCctxByStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCctxByStatusResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCctxByStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCctxByStatusResponse.Merge(m, src) +} +func (m *QueryCctxByStatusResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCctxByStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCctxByStatusResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCctxByStatusResponse proto.InternalMessageInfo + +func (m *QueryCctxByStatusResponse) GetCrossChainTx() []CrossChainTx { + if m != nil { + return m.CrossChainTx + } + return nil +} + type QueryTssHistoryRequest struct { } @@ -38,7 +126,7 @@ func (m *QueryTssHistoryRequest) Reset() { *m = QueryTssHistoryRequest{} func (m *QueryTssHistoryRequest) String() string { return proto.CompactTextString(m) } func (*QueryTssHistoryRequest) ProtoMessage() {} func (*QueryTssHistoryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{0} + return fileDescriptor_65a992045e92a606, []int{2} } func (m *QueryTssHistoryRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -75,7 +163,7 @@ func (m *QueryTssHistoryResponse) Reset() { *m = QueryTssHistoryResponse func (m *QueryTssHistoryResponse) String() string { return proto.CompactTextString(m) } func (*QueryTssHistoryResponse) ProtoMessage() {} func (*QueryTssHistoryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{1} + return fileDescriptor_65a992045e92a606, []int{3} } func (m *QueryTssHistoryResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -119,7 +207,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{2} + return fileDescriptor_65a992045e92a606, []int{4} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -158,7 +246,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{3} + return fileDescriptor_65a992045e92a606, []int{5} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,7 +291,7 @@ func (m *QueryGetOutTxTrackerRequest) Reset() { *m = QueryGetOutTxTracke func (m *QueryGetOutTxTrackerRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetOutTxTrackerRequest) ProtoMessage() {} func (*QueryGetOutTxTrackerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{4} + return fileDescriptor_65a992045e92a606, []int{6} } func (m *QueryGetOutTxTrackerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -254,7 +342,7 @@ func (m *QueryGetOutTxTrackerResponse) Reset() { *m = QueryGetOutTxTrack func (m *QueryGetOutTxTrackerResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetOutTxTrackerResponse) ProtoMessage() {} func (*QueryGetOutTxTrackerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{5} + return fileDescriptor_65a992045e92a606, []int{7} } func (m *QueryGetOutTxTrackerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -298,7 +386,7 @@ func (m *QueryAllOutTxTrackerRequest) Reset() { *m = QueryAllOutTxTracke func (m *QueryAllOutTxTrackerRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllOutTxTrackerRequest) ProtoMessage() {} func (*QueryAllOutTxTrackerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{6} + return fileDescriptor_65a992045e92a606, []int{8} } func (m *QueryAllOutTxTrackerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -343,7 +431,7 @@ func (m *QueryAllOutTxTrackerResponse) Reset() { *m = QueryAllOutTxTrack func (m *QueryAllOutTxTrackerResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllOutTxTrackerResponse) ProtoMessage() {} func (*QueryAllOutTxTrackerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{7} + return fileDescriptor_65a992045e92a606, []int{9} } func (m *QueryAllOutTxTrackerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -395,7 +483,7 @@ func (m *QueryAllOutTxTrackerByChainRequest) Reset() { *m = QueryAllOutT func (m *QueryAllOutTxTrackerByChainRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllOutTxTrackerByChainRequest) ProtoMessage() {} func (*QueryAllOutTxTrackerByChainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{8} + return fileDescriptor_65a992045e92a606, []int{10} } func (m *QueryAllOutTxTrackerByChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -447,7 +535,7 @@ func (m *QueryAllOutTxTrackerByChainResponse) Reset() { *m = QueryAllOut func (m *QueryAllOutTxTrackerByChainResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllOutTxTrackerByChainResponse) ProtoMessage() {} func (*QueryAllOutTxTrackerByChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{9} + return fileDescriptor_65a992045e92a606, []int{11} } func (m *QueryAllOutTxTrackerByChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -499,7 +587,7 @@ func (m *QueryAllInTxTrackerByChainRequest) Reset() { *m = QueryAllInTxT func (m *QueryAllInTxTrackerByChainRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxTrackerByChainRequest) ProtoMessage() {} func (*QueryAllInTxTrackerByChainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{10} + return fileDescriptor_65a992045e92a606, []int{12} } func (m *QueryAllInTxTrackerByChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -551,7 +639,7 @@ func (m *QueryAllInTxTrackerByChainResponse) Reset() { *m = QueryAllInTx func (m *QueryAllInTxTrackerByChainResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxTrackerByChainResponse) ProtoMessage() {} func (*QueryAllInTxTrackerByChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{11} + return fileDescriptor_65a992045e92a606, []int{13} } func (m *QueryAllInTxTrackerByChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -601,7 +689,7 @@ func (m *QueryAllInTxTrackersRequest) Reset() { *m = QueryAllInTxTracker func (m *QueryAllInTxTrackersRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxTrackersRequest) ProtoMessage() {} func (*QueryAllInTxTrackersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{12} + return fileDescriptor_65a992045e92a606, []int{14} } func (m *QueryAllInTxTrackersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -638,7 +726,7 @@ func (m *QueryAllInTxTrackersResponse) Reset() { *m = QueryAllInTxTracke func (m *QueryAllInTxTrackersResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxTrackersResponse) ProtoMessage() {} func (*QueryAllInTxTrackersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{13} + return fileDescriptor_65a992045e92a606, []int{15} } func (m *QueryAllInTxTrackersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -682,7 +770,7 @@ func (m *QueryGetInTxHashToCctxRequest) Reset() { *m = QueryGetInTxHashT func (m *QueryGetInTxHashToCctxRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetInTxHashToCctxRequest) ProtoMessage() {} func (*QueryGetInTxHashToCctxRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{14} + return fileDescriptor_65a992045e92a606, []int{16} } func (m *QueryGetInTxHashToCctxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -726,7 +814,7 @@ func (m *QueryGetInTxHashToCctxResponse) Reset() { *m = QueryGetInTxHash func (m *QueryGetInTxHashToCctxResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetInTxHashToCctxResponse) ProtoMessage() {} func (*QueryGetInTxHashToCctxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{15} + return fileDescriptor_65a992045e92a606, []int{17} } func (m *QueryGetInTxHashToCctxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -770,7 +858,7 @@ func (m *QueryInTxHashToCctxDataRequest) Reset() { *m = QueryInTxHashToC func (m *QueryInTxHashToCctxDataRequest) String() string { return proto.CompactTextString(m) } func (*QueryInTxHashToCctxDataRequest) ProtoMessage() {} func (*QueryInTxHashToCctxDataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{16} + return fileDescriptor_65a992045e92a606, []int{18} } func (m *QueryInTxHashToCctxDataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -814,7 +902,7 @@ func (m *QueryInTxHashToCctxDataResponse) Reset() { *m = QueryInTxHashTo func (m *QueryInTxHashToCctxDataResponse) String() string { return proto.CompactTextString(m) } func (*QueryInTxHashToCctxDataResponse) ProtoMessage() {} func (*QueryInTxHashToCctxDataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{17} + return fileDescriptor_65a992045e92a606, []int{19} } func (m *QueryInTxHashToCctxDataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -858,7 +946,7 @@ func (m *QueryAllInTxHashToCctxRequest) Reset() { *m = QueryAllInTxHashT func (m *QueryAllInTxHashToCctxRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxHashToCctxRequest) ProtoMessage() {} func (*QueryAllInTxHashToCctxRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{18} + return fileDescriptor_65a992045e92a606, []int{20} } func (m *QueryAllInTxHashToCctxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -903,7 +991,7 @@ func (m *QueryAllInTxHashToCctxResponse) Reset() { *m = QueryAllInTxHash func (m *QueryAllInTxHashToCctxResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllInTxHashToCctxResponse) ProtoMessage() {} func (*QueryAllInTxHashToCctxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{19} + return fileDescriptor_65a992045e92a606, []int{21} } func (m *QueryAllInTxHashToCctxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -947,14 +1035,15 @@ func (m *QueryAllInTxHashToCctxResponse) GetPagination() *query.PageResponse { } type QueryGetTssAddressRequest struct { - TssPubKey string `protobuf:"bytes,1,opt,name=tss_pub_key,json=tssPubKey,proto3" json:"tss_pub_key,omitempty"` + TssPubKey string `protobuf:"bytes,1,opt,name=tss_pub_key,json=tssPubKey,proto3" json:"tss_pub_key,omitempty"` + BitcoinChainId int64 `protobuf:"varint,2,opt,name=bitcoin_chain_id,json=bitcoinChainId,proto3" json:"bitcoin_chain_id,omitempty"` } func (m *QueryGetTssAddressRequest) Reset() { *m = QueryGetTssAddressRequest{} } func (m *QueryGetTssAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetTssAddressRequest) ProtoMessage() {} func (*QueryGetTssAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{20} + return fileDescriptor_65a992045e92a606, []int{22} } func (m *QueryGetTssAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -990,6 +1079,13 @@ func (m *QueryGetTssAddressRequest) GetTssPubKey() string { return "" } +func (m *QueryGetTssAddressRequest) GetBitcoinChainId() int64 { + if m != nil { + return m.BitcoinChainId + } + return 0 +} + type QueryGetTssAddressResponse struct { Eth string `protobuf:"bytes,1,opt,name=eth,proto3" json:"eth,omitempty"` Btc string `protobuf:"bytes,2,opt,name=btc,proto3" json:"btc,omitempty"` @@ -999,7 +1095,7 @@ func (m *QueryGetTssAddressResponse) Reset() { *m = QueryGetTssAddressRe func (m *QueryGetTssAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetTssAddressResponse) ProtoMessage() {} func (*QueryGetTssAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{21} + return fileDescriptor_65a992045e92a606, []int{23} } func (m *QueryGetTssAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1049,7 +1145,7 @@ func (m *QueryGetTSSRequest) Reset() { *m = QueryGetTSSRequest{} } func (m *QueryGetTSSRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetTSSRequest) ProtoMessage() {} func (*QueryGetTSSRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{22} + return fileDescriptor_65a992045e92a606, []int{24} } func (m *QueryGetTSSRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1086,7 +1182,7 @@ func (m *QueryGetTSSResponse) Reset() { *m = QueryGetTSSResponse{} } func (m *QueryGetTSSResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetTSSResponse) ProtoMessage() {} func (*QueryGetTSSResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{23} + return fileDescriptor_65a992045e92a606, []int{25} } func (m *QueryGetTSSResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1130,7 +1226,7 @@ func (m *QueryGetGasPriceRequest) Reset() { *m = QueryGetGasPriceRequest func (m *QueryGetGasPriceRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetGasPriceRequest) ProtoMessage() {} func (*QueryGetGasPriceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{24} + return fileDescriptor_65a992045e92a606, []int{26} } func (m *QueryGetGasPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1174,7 +1270,7 @@ func (m *QueryGetGasPriceResponse) Reset() { *m = QueryGetGasPriceRespon func (m *QueryGetGasPriceResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetGasPriceResponse) ProtoMessage() {} func (*QueryGetGasPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{25} + return fileDescriptor_65a992045e92a606, []int{27} } func (m *QueryGetGasPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1218,7 +1314,7 @@ func (m *QueryAllGasPriceRequest) Reset() { *m = QueryAllGasPriceRequest func (m *QueryAllGasPriceRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllGasPriceRequest) ProtoMessage() {} func (*QueryAllGasPriceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{26} + return fileDescriptor_65a992045e92a606, []int{28} } func (m *QueryAllGasPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1263,7 +1359,7 @@ func (m *QueryAllGasPriceResponse) Reset() { *m = QueryAllGasPriceRespon func (m *QueryAllGasPriceResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllGasPriceResponse) ProtoMessage() {} func (*QueryAllGasPriceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{27} + return fileDescriptor_65a992045e92a606, []int{29} } func (m *QueryAllGasPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1314,7 +1410,7 @@ func (m *QueryGetChainNoncesRequest) Reset() { *m = QueryGetChainNoncesR func (m *QueryGetChainNoncesRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetChainNoncesRequest) ProtoMessage() {} func (*QueryGetChainNoncesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{28} + return fileDescriptor_65a992045e92a606, []int{30} } func (m *QueryGetChainNoncesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1358,7 +1454,7 @@ func (m *QueryGetChainNoncesResponse) Reset() { *m = QueryGetChainNonces func (m *QueryGetChainNoncesResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetChainNoncesResponse) ProtoMessage() {} func (*QueryGetChainNoncesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{29} + return fileDescriptor_65a992045e92a606, []int{31} } func (m *QueryGetChainNoncesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1402,7 +1498,7 @@ func (m *QueryAllChainNoncesRequest) Reset() { *m = QueryAllChainNoncesR func (m *QueryAllChainNoncesRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllChainNoncesRequest) ProtoMessage() {} func (*QueryAllChainNoncesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{30} + return fileDescriptor_65a992045e92a606, []int{32} } func (m *QueryAllChainNoncesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1447,7 +1543,7 @@ func (m *QueryAllChainNoncesResponse) Reset() { *m = QueryAllChainNonces func (m *QueryAllChainNoncesResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllChainNoncesResponse) ProtoMessage() {} func (*QueryAllChainNoncesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{31} + return fileDescriptor_65a992045e92a606, []int{33} } func (m *QueryAllChainNoncesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1497,7 +1593,7 @@ func (m *QueryAllPendingNoncesRequest) Reset() { *m = QueryAllPendingNon func (m *QueryAllPendingNoncesRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllPendingNoncesRequest) ProtoMessage() {} func (*QueryAllPendingNoncesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{32} + return fileDescriptor_65a992045e92a606, []int{34} } func (m *QueryAllPendingNoncesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1534,7 +1630,7 @@ func (m *QueryAllPendingNoncesResponse) Reset() { *m = QueryAllPendingNo func (m *QueryAllPendingNoncesResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllPendingNoncesResponse) ProtoMessage() {} func (*QueryAllPendingNoncesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{33} + return fileDescriptor_65a992045e92a606, []int{35} } func (m *QueryAllPendingNoncesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1578,7 +1674,7 @@ func (m *QueryPendingNoncesByChainRequest) Reset() { *m = QueryPendingNo func (m *QueryPendingNoncesByChainRequest) String() string { return proto.CompactTextString(m) } func (*QueryPendingNoncesByChainRequest) ProtoMessage() {} func (*QueryPendingNoncesByChainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{34} + return fileDescriptor_65a992045e92a606, []int{36} } func (m *QueryPendingNoncesByChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1622,7 +1718,7 @@ func (m *QueryPendingNoncesByChainResponse) Reset() { *m = QueryPendingN func (m *QueryPendingNoncesByChainResponse) String() string { return proto.CompactTextString(m) } func (*QueryPendingNoncesByChainResponse) ProtoMessage() {} func (*QueryPendingNoncesByChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{35} + return fileDescriptor_65a992045e92a606, []int{37} } func (m *QueryPendingNoncesByChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1666,7 +1762,7 @@ func (m *QueryGetLastBlockHeightRequest) Reset() { *m = QueryGetLastBloc func (m *QueryGetLastBlockHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetLastBlockHeightRequest) ProtoMessage() {} func (*QueryGetLastBlockHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{36} + return fileDescriptor_65a992045e92a606, []int{38} } func (m *QueryGetLastBlockHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1710,7 +1806,7 @@ func (m *QueryGetLastBlockHeightResponse) Reset() { *m = QueryGetLastBlo func (m *QueryGetLastBlockHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetLastBlockHeightResponse) ProtoMessage() {} func (*QueryGetLastBlockHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{37} + return fileDescriptor_65a992045e92a606, []int{39} } func (m *QueryGetLastBlockHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1754,7 +1850,7 @@ func (m *QueryAllLastBlockHeightRequest) Reset() { *m = QueryAllLastBloc func (m *QueryAllLastBlockHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllLastBlockHeightRequest) ProtoMessage() {} func (*QueryAllLastBlockHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{38} + return fileDescriptor_65a992045e92a606, []int{40} } func (m *QueryAllLastBlockHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1799,7 +1895,7 @@ func (m *QueryAllLastBlockHeightResponse) Reset() { *m = QueryAllLastBlo func (m *QueryAllLastBlockHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllLastBlockHeightResponse) ProtoMessage() {} func (*QueryAllLastBlockHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{39} + return fileDescriptor_65a992045e92a606, []int{41} } func (m *QueryAllLastBlockHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1850,7 +1946,7 @@ func (m *QueryGetCctxRequest) Reset() { *m = QueryGetCctxRequest{} } func (m *QueryGetCctxRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetCctxRequest) ProtoMessage() {} func (*QueryGetCctxRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{40} + return fileDescriptor_65a992045e92a606, []int{42} } func (m *QueryGetCctxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1895,7 +1991,7 @@ func (m *QueryGetCctxByNonceRequest) Reset() { *m = QueryGetCctxByNonceR func (m *QueryGetCctxByNonceRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetCctxByNonceRequest) ProtoMessage() {} func (*QueryGetCctxByNonceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{41} + return fileDescriptor_65a992045e92a606, []int{43} } func (m *QueryGetCctxByNonceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1946,7 +2042,7 @@ func (m *QueryGetCctxResponse) Reset() { *m = QueryGetCctxResponse{} } func (m *QueryGetCctxResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetCctxResponse) ProtoMessage() {} func (*QueryGetCctxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{42} + return fileDescriptor_65a992045e92a606, []int{44} } func (m *QueryGetCctxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1990,7 +2086,7 @@ func (m *QueryAllCctxRequest) Reset() { *m = QueryAllCctxRequest{} } func (m *QueryAllCctxRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllCctxRequest) ProtoMessage() {} func (*QueryAllCctxRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{43} + return fileDescriptor_65a992045e92a606, []int{45} } func (m *QueryAllCctxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2035,7 +2131,7 @@ func (m *QueryAllCctxResponse) Reset() { *m = QueryAllCctxResponse{} } func (m *QueryAllCctxResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllCctxResponse) ProtoMessage() {} func (*QueryAllCctxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{44} + return fileDescriptor_65a992045e92a606, []int{46} } func (m *QueryAllCctxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2087,7 +2183,7 @@ func (m *QueryAllCctxPendingRequest) Reset() { *m = QueryAllCctxPendingR func (m *QueryAllCctxPendingRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllCctxPendingRequest) ProtoMessage() {} func (*QueryAllCctxPendingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{45} + return fileDescriptor_65a992045e92a606, []int{47} } func (m *QueryAllCctxPendingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2139,7 +2235,7 @@ func (m *QueryAllCctxPendingResponse) Reset() { *m = QueryAllCctxPending func (m *QueryAllCctxPendingResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllCctxPendingResponse) ProtoMessage() {} func (*QueryAllCctxPendingResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{46} + return fileDescriptor_65a992045e92a606, []int{48} } func (m *QueryAllCctxPendingResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2189,7 +2285,7 @@ func (m *QueryLastZetaHeightRequest) Reset() { *m = QueryLastZetaHeightR func (m *QueryLastZetaHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryLastZetaHeightRequest) ProtoMessage() {} func (*QueryLastZetaHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{47} + return fileDescriptor_65a992045e92a606, []int{49} } func (m *QueryLastZetaHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2226,7 +2322,7 @@ func (m *QueryLastZetaHeightResponse) Reset() { *m = QueryLastZetaHeight func (m *QueryLastZetaHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryLastZetaHeightResponse) ProtoMessage() {} func (*QueryLastZetaHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{48} + return fileDescriptor_65a992045e92a606, []int{50} } func (m *QueryLastZetaHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2271,7 +2367,7 @@ func (m *QueryConvertGasToZetaRequest) Reset() { *m = QueryConvertGasToZ func (m *QueryConvertGasToZetaRequest) String() string { return proto.CompactTextString(m) } func (*QueryConvertGasToZetaRequest) ProtoMessage() {} func (*QueryConvertGasToZetaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{49} + return fileDescriptor_65a992045e92a606, []int{51} } func (m *QueryConvertGasToZetaRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2324,7 +2420,7 @@ func (m *QueryConvertGasToZetaResponse) Reset() { *m = QueryConvertGasTo func (m *QueryConvertGasToZetaResponse) String() string { return proto.CompactTextString(m) } func (*QueryConvertGasToZetaResponse) ProtoMessage() {} func (*QueryConvertGasToZetaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{50} + return fileDescriptor_65a992045e92a606, []int{52} } func (m *QueryConvertGasToZetaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2381,7 +2477,7 @@ func (m *QueryMessagePassingProtocolFeeRequest) Reset() { *m = QueryMess func (m *QueryMessagePassingProtocolFeeRequest) String() string { return proto.CompactTextString(m) } func (*QueryMessagePassingProtocolFeeRequest) ProtoMessage() {} func (*QueryMessagePassingProtocolFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{51} + return fileDescriptor_65a992045e92a606, []int{53} } func (m *QueryMessagePassingProtocolFeeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2420,7 +2516,7 @@ func (m *QueryMessagePassingProtocolFeeResponse) Reset() { func (m *QueryMessagePassingProtocolFeeResponse) String() string { return proto.CompactTextString(m) } func (*QueryMessagePassingProtocolFeeResponse) ProtoMessage() {} func (*QueryMessagePassingProtocolFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{52} + return fileDescriptor_65a992045e92a606, []int{54} } func (m *QueryMessagePassingProtocolFeeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2464,7 +2560,7 @@ func (m *QueryZEVMGetTransactionReceiptRequest) Reset() { *m = QueryZEVM func (m *QueryZEVMGetTransactionReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetTransactionReceiptRequest) ProtoMessage() {} func (*QueryZEVMGetTransactionReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{53} + return fileDescriptor_65a992045e92a606, []int{55} } func (m *QueryZEVMGetTransactionReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2521,7 +2617,7 @@ func (m *QueryZEVMGetTransactionReceiptResponse) Reset() { func (m *QueryZEVMGetTransactionReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetTransactionReceiptResponse) ProtoMessage() {} func (*QueryZEVMGetTransactionReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{54} + return fileDescriptor_65a992045e92a606, []int{56} } func (m *QueryZEVMGetTransactionReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2651,7 +2747,7 @@ func (m *Log) Reset() { *m = Log{} } func (m *Log) String() string { return proto.CompactTextString(m) } func (*Log) ProtoMessage() {} func (*Log) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{55} + return fileDescriptor_65a992045e92a606, []int{57} } func (m *Log) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2751,7 +2847,7 @@ func (m *QueryZEVMGetTransactionRequest) Reset() { *m = QueryZEVMGetTran func (m *QueryZEVMGetTransactionRequest) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetTransactionRequest) ProtoMessage() {} func (*QueryZEVMGetTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{56} + return fileDescriptor_65a992045e92a606, []int{58} } func (m *QueryZEVMGetTransactionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2811,7 +2907,7 @@ func (m *QueryZEVMGetTransactionResponse) Reset() { *m = QueryZEVMGetTra func (m *QueryZEVMGetTransactionResponse) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetTransactionResponse) ProtoMessage() {} func (*QueryZEVMGetTransactionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{57} + return fileDescriptor_65a992045e92a606, []int{59} } func (m *QueryZEVMGetTransactionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2967,7 +3063,7 @@ func (m *QueryZEVMGetBlockByNumberRequest) Reset() { *m = QueryZEVMGetBl func (m *QueryZEVMGetBlockByNumberRequest) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetBlockByNumberRequest) ProtoMessage() {} func (*QueryZEVMGetBlockByNumberRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{58} + return fileDescriptor_65a992045e92a606, []int{60} } func (m *QueryZEVMGetBlockByNumberRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3031,7 +3127,7 @@ func (m *QueryZEVMGetBlockByNumberResponse) Reset() { *m = QueryZEVMGetB func (m *QueryZEVMGetBlockByNumberResponse) String() string { return proto.CompactTextString(m) } func (*QueryZEVMGetBlockByNumberResponse) ProtoMessage() {} func (*QueryZEVMGetBlockByNumberResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{59} + return fileDescriptor_65a992045e92a606, []int{61} } func (m *QueryZEVMGetBlockByNumberResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3208,6 +3304,8 @@ func (m *QueryZEVMGetBlockByNumberResponse) GetMixHash() string { } func init() { + proto.RegisterType((*QueryCctxByStatusRequest)(nil), "zetachain.zetacore.crosschain.QueryCctxByStatusRequest") + proto.RegisterType((*QueryCctxByStatusResponse)(nil), "zetachain.zetacore.crosschain.QueryCctxByStatusResponse") proto.RegisterType((*QueryTssHistoryRequest)(nil), "zetachain.zetacore.crosschain.QueryTssHistoryRequest") proto.RegisterType((*QueryTssHistoryResponse)(nil), "zetachain.zetacore.crosschain.QueryTssHistoryResponse") proto.RegisterType((*QueryParamsRequest)(nil), "zetachain.zetacore.crosschain.QueryParamsRequest") @@ -3273,204 +3371,211 @@ func init() { func init() { proto.RegisterFile("crosschain/query.proto", fileDescriptor_65a992045e92a606) } var fileDescriptor_65a992045e92a606 = []byte{ - // 3151 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5b, 0xdd, 0x6f, 0x1b, 0xc7, - 0x11, 0xf7, 0x89, 0xfa, 0x5c, 0x4a, 0x96, 0xbc, 0x56, 0x1c, 0x86, 0xb1, 0x45, 0xe7, 0x1c, 0x5b, - 0x8e, 0x3f, 0xc8, 0x58, 0xb1, 0x95, 0xc4, 0x76, 0xd2, 0x48, 0x76, 0xac, 0x18, 0x51, 0x12, 0xf5, - 0xa4, 0xf4, 0xc3, 0x45, 0x4b, 0x9c, 0xc8, 0x35, 0x75, 0x30, 0xc9, 0x63, 0x6e, 0x97, 0x82, 0x14, - 0x43, 0x2d, 0x90, 0x87, 0x3e, 0x07, 0x28, 0xd0, 0xbe, 0xf4, 0xb5, 0x1f, 0x0f, 0x7d, 0x28, 0xd0, - 0xa0, 0x29, 0x50, 0x20, 0x45, 0xd1, 0xd6, 0xcd, 0x63, 0xd0, 0x02, 0x45, 0x3f, 0x00, 0xa2, 0x48, - 0xfa, 0xc4, 0xff, 0xa0, 0x40, 0x1f, 0x8a, 0x9d, 0x9b, 0xe3, 0xed, 0xf1, 0xee, 0xc4, 0x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f, 0x63, 0xce, 0xe2, 0x51, 0x51, 0xe0, 0x55, 0x92, 0xda, 0x58, 0x5f, 0xc7, 0x55, - 0x4b, 0x90, 0x20, 0x19, 0xf2, 0x71, 0xbd, 0x80, 0x69, 0xd7, 0x0a, 0x13, 0x2b, 0x26, 0x5f, 0x93, - 0x79, 0xab, 0x72, 0x54, 0x59, 0xf5, 0x32, 0xdb, 0x41, 0x8c, 0x6e, 0x47, 0x2f, 0x92, 0x4c, 0x98, - 0xc1, 0x4f, 0xd4, 0x3c, 0x1a, 0xe2, 0x98, 0xef, 0x81, 0xa3, 0x23, 0xa2, 0xc3, 0xa8, 0x9b, 0x88, - 0x68, 0xa9, 0x5a, 0xed, 0x46, 0x34, 0x28, 0xff, 0xfc, 0xa9, 0x86, 0x4a, 0x04, 0xe6, 0x88, 0x54, - 0x22, 0xd5, 0x97, 0x12, 0x83, 0xf3, 0xc0, 0x05, 0xdf, 0x89, 0x20, 0x8e, 0xdf, 0x84, 0x7b, 0xc9, - 0xfe, 0x4b, 0xf4, 0xc0, 0x4f, 0x3c, 0x03, 0x3c, 0xa8, 0xe0, 0x2a, 0x49, 0x2b, 0x64, 0x34, 0x63, - 0xaf, 0x0d, 0x5d, 0x15, 0xa4, 0xb2, 0xeb, 0x65, 0x04, 0xb8, 0x54, 0xad, 0x46, 0x00, 0x1c, 0xd4, - 0x8a, 0x7d, 0xa0, 0xf9, 0x87, 0x58, 0x22, 0x9d, 0x52, 0x87, 0xd0, 0x69, 0x70, 0xab, 0x37, 0xe7, - 0x9f, 0xad, 0x6b, 0xac, 0x5e, 0xb6, 0xea, 0x95, 0x80, 0x79, 0x74, 0xe1, 0xef, 0xc8, 0x5d, 0xe3, - 0xa8, 0xd7, 0x3a, 0x39, 0xda, 0x70, 0x07, 0xf0, 0x46, 0x8a, 0xaa, 0x5d, 0xea, 0x75, 0x21, 0x09, - 0x48, 0x9b, 0x6a, 0xa8, 0x5d, 0xfd, 0x25, 0x72, 0xda, 0xbd, 0xf4,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x77, 0xf2, 0x70, 0x8d, - 0xbe, 0xf7, 0x4e, 0xee, 0xf3, 0xc0, 0x2d, 0x34, 0x58, 0x13, 0x4f, 0x86, 0x3a, 0xb2, 0xca, 0x9e, - 0x0c, 0x75, 0x74, 0x09, 0xbe, 0xe7, 0x05, 0xa1, 0x1a, 0x44, 0xf9, 0x63, 0x8d, 0x10, 0xff, 0x7f, - 0x65, 0xe8, 0xb5, 0x24, 0x33, 0x87, 0xfe, 0xeb, 0x26, 0xbb, 0x78, 0x50, 0x36, 0x04, 0xfb, 0x0c, - 0x80, 0x3d, 0x43, 0x9f, 0x8a, 0x01, 0x2b, 0x3a, 0x2c, 0xcb, 0xaf, 0x7f, 0xfc, 0xe9, 0x9c, 0xf6, - 0xc9, 0xa7, 0x73, 0xda, 0x3f, 0x3f, 0x9d, 0xd3, 0xde, 0xff, 0x6c, 0xee, 0xc8, 0x27, 0x9f, 0xcd, - 0x1d, 0xf9, 0xeb, 0x67, 0x73, 0x47, 0xee, 0x5d, 0xa9, 0x58, 0x62, 0xab, 0xb9, 0x99, 0x2f, 0xd9, - 0x35, 0x55, 0x8c, 0x87, 0xa3, 0xb0, 0x13, 0x90, 0xb8, 0xdb, 0x60, 0x7c, 0x73, 0x14, 0xd2, 0x9e, - 0xe7, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x16, 0xbf, 0x39, 0xb6, 0x14, 0x36, 0x00, 0x00, + // 3255 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5b, 0xcd, 0x6f, 0x1b, 0xc7, + 0x15, 0xf7, 0x8a, 0xfa, 0x1c, 0x7d, 0x7a, 0xac, 0x38, 0x0c, 0x63, 0x8b, 0xce, 0x3a, 0xb6, 0xe5, + 0x2f, 0x32, 0x56, 0x6c, 0x25, 0xb1, 0x9d, 0x34, 0x92, 0x1d, 0x2b, 0x46, 0x94, 0x44, 0x5d, 0x29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, 0xd1, 0x12, 0xd1, + 0x62, 0xd4, 0x4d, 0x44, 0xb4, 0x54, 0x2e, 0xb7, 0x23, 0xea, 0x57, 0x24, 0xff, 0x54, 0x43, 0x25, + 0x42, 0x6b, 0x44, 0x2a, 0x91, 0xea, 0x49, 0x89, 0xfe, 0xc5, 0xea, 0x42, 0x10, 0x44, 0x10, 0x57, + 0x6f, 0xc0, 0x43, 0xd9, 0xfe, 0x2e, 0x7a, 0x10, 0x94, 0xa8, 0x21, 0x1e, 0x54, 0x70, 0x95, 0x8c, + 0x2b, 0x64, 0x34, 0x63, 0xb7, 0xd4, 0xaf, 0x0a, 0x52, 0xd9, 0xf5, 0x22, 0x02, 0x5c, 0x2a, 0x97, + 0x23, 0x00, 0xf6, 0xcb, 0x63, 0x1f, 0x68, 0xc1, 0x71, 0x97, 0x48, 0xa7, 0xd4, 0x21, 0x74, 0xea, + 0x9f, 0xf7, 0xe6, 0x82, 0x53, 0x78, 0x8d, 0x55, 0x8b, 0x76, 0xb5, 0x14, 0x32, 0x8f, 0x2e, 0x82, + 0xdc, 0xdd, 0x36, 0x8e, 0x7a, 0xad, 0x93, 0xa9, 0x9a, 0x37, 0x80, 0x8f, 0xe3, 0xa8, 0xda, 0xa5, + 0x6e, 0x8f, 0x2e, 0x21, 0x69, 0x93, 0x35, 0xb5, 0xab, 0xbf, 0x48, 0x4e, 0x79, 0x8f, 0x47, 0x2a, + 0x35, 0x71, 0x15, 0xa6, 0x7f, 0x0b, 0xab, 0xb8, 0x68, 0x76, 0x04, 0xfe, 0xf5, 0x08, 0xe0, 0xda, + 0x41, 0x81, 0xfb, 0x07, 0x5e, 0x18, 0xfe, 0x62, 0x50, 0x29, 0xac, 0x9a, 0x5c, 0x2c, 0x97, 0x1d, + 0xeb, 0xc1, 0xab, 0xf0, 0x16, 0x60, 0xff, 0x6d, 0xf1, 0x10, 0x0f, 0xe9, 0x28, 0x3e, 0x44, 0xfd, + 0x35, 0x32, 0xdd, 0x36, 0x84, 0xb0,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f, 0x58, 0x79, 0x6c, 0xf9, 0x58, 0xb3, 0x91, 0x9d, 0xf6, 0xc7, 0xfc, 0xa7, 0xa2, 0x76, 0x02, + 0x7d, 0x85, 0x1c, 0xb3, 0xea, 0x95, 0x7a, 0xd9, 0x14, 0xf6, 0x36, 0x2b, 0x94, 0x4c, 0x5e, 0xa8, + 0x73, 0x56, 0x4c, 0x0f, 0x82, 0x88, 0xc7, 0x9a, 0x8d, 0xec, 0xd1, 0x60, 0x78, 0xc5, 0xe4, 0x6f, + 0x71, 0x56, 0x34, 0x3a, 0x49, 0xf4, 0x04, 0x19, 0xbc, 0xef, 0x3a, 0x95, 0xf4, 0x10, 0xf0, 0x8d, + 0x36, 0x1b, 0x59, 0xe8, 0x1b, 0xf0, 0x97, 0x9e, 0x85, 0x18, 0xf5, 0x24, 0x0f, 0xc3, 0x8c, 0xf1, + 0x66, 0x23, 0x3b, 0x52, 0x42, 0x79, 0x7e, 0x43, 0x9a, 0xab, 0xec, 0x94, 0x78, 0x61, 0xb3, 0xec, + 0x38, 0x95, 0xf4, 0x48, 0x60, 0x2e, 0x49, 0x5d, 0x96, 0x44, 0x23, 0x68, 0x52, 0xbd, 0xf5, 0x12, + 0x7f, 0x14, 0x66, 0x92, 0x66, 0x23, 0x8b, 0x14, 0xff, 0x2d, 0x3d, 0x3d, 0x4e, 0x06, 0x84, 0x93, + 0x1e, 0x83, 0xf1, 0xe1, 0x66, 0x23, 0x3b, 0x20, 0x1c, 0x63, 0x40, 0x38, 0xd2, 0x6c, 0x22, 0x70, + 0x9b, 0xe7, 0x1e, 0x12, 0x98, 0x4d, 0x19, 0x03, 0x27, 0xb5, 0x13, 0xe8, 0x12, 0x39, 0xaa, 0xf2, + 0x7b, 0x47, 0xe5, 0x38, 0x08, 0x98, 0x6d, 0x36, 0xb2, 0xaa, 0xf0, 0xbb, 0x72, 0xcc, 0xe8, 0xa0, + 0xd0, 0x45, 0x32, 0x28, 0x75, 0x49, 0x4f, 0x24, 0x7a, 0x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+ 0x46, 0xd6, 0x23, 0x18, 0xde, 0x8f, 0x9c, 0xe0, 0xd5, 0x8b, 0xa3, 0xc1, 0x04, 0x20, 0x60, 0xe9, + 0x18, 0xbb, 0xaf, 0x23, 0x43, 0x8b, 0x1c, 0x68, 0x5f, 0x66, 0xc9, 0xd0, 0xb6, 0x59, 0xae, 0x33, + 0xdc, 0xce, 0xb0, 0x36, 0x10, 0x0c, 0xef, 0x47, 0xea, 0x26, 0x76, 0x6b, 0x2c, 0x3d, 0x11, 0xe8, + 0x26, 0xfb, 0x06, 0xfc, 0xa5, 0x79, 0x32, 0x6e, 0x5a, 0x16, 0xf3, 0x6f, 0xdc, 0x26, 0xe5, 0x0e, + 0x5c, 0x9e, 0x6a, 0x36, 0xb2, 0xc4, 0x23, 0xaf, 0xda, 0xb2, 0x12, 0x0a, 0xda, 0x32, 0x39, 0xb6, + 0x8a, 0xad, 0xa9, 0x20, 0x39, 0xe2, 0xf9, 0x1e, 0x1c, 0xf4, 0xc7, 0x88, 0xb6, 0x9d, 0x9e, 0x86, + 0x09, 0x43, 0xcd, 0x46, 0x56, 0xdb, 0x36, 0xb4, 0x6d, 0x49, 0x74, 0xd3, 0x33, 0x01, 0xd1, 0x35, + 0x34, 0x57, 0x12, 0x79, 0xfa, 0x68, 0x40, 0xe4, 0x86, 0xc6, 0xf5, 0xeb, 0xf8, 0x30, 0x8a, 0xa1, + 0x07, 0xc7, 0xef, 0xf2, 0x2e, 0xc6, 0x07, 0xc6, 0xec, 0x71, 0x32, 0xbc, 0x15, 0x54, 0x27, 0x83, + 0x06, 0xf6, 0xf4, 0xbf, 0x8d, 0xe0, 0xa3, 0x68, 0x34, 0x33, 0x46, 0xae, 0x4e, 0x86, 0x31, 0x0a, + 0xb5, 0x20, 0x1f, 0x7b, 0x14, 0x03, 0x7f, 0x5b, 0x71, 0x31, 0x10, 0x19, 0x17, 0x79, 0x32, 0x5e, + 0x33, 0x5d, 0x56, 0x15, 0x5e, 0xf0, 0x7b, 0x01,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0x60, 0x45, 0x80, 0xec, 0x43, 0x8d, 0x4c, + 0xa8, 0xff, 0x8c, 0x44, 0x13, 0x55, 0xa6, 0x11, 0xff, 0x1d, 0x95, 0x79, 0xfe, 0xe0, 0x8c, 0x08, + 0xf7, 0x2a, 0xc0, 0xcd, 0xd1, 0x4b, 0xfb, 0x44, 0xc4, 0x26, 0x32, 0xe5, 0x1f, 0x7a, 0x77, 0xb4, + 0x7b, 0xcb, 0xaf, 0x7d, 0xf2, 0xd9, 0x9c, 0xf6, 0xe9, 0x67, 0x73, 0xda, 0x3f, 0x3f, 0x9b, 0xd3, + 0xde, 0x7f, 0x34, 0x77, 0xe4, 0xd3, 0x47, 0x73, 0x47, 0xfe, 0xfa, 0x68, 0xee, 0xc8, 0xbd, 0x2b, + 0x25, 0x5b, 0x6c, 0xd5, 0x37, 0x73, 0x96, 0x53, 0x51, 0x25, 0xfa, 0xa0, 0xf2, 0x3b, 0x21, 0x5b, + 0xec, 0xd6, 0x18, 0xdf, 0x1c, 0x86, 0x82, 0xed, 0xd9, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x85, + 0xef, 0x5f, 0x94, 0xcb, 0x37, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3531,6 +3636,7 @@ type QueryClient interface { // Queries a list of lastMetaHeight items. LastZetaHeight(ctx context.Context, in *QueryLastZetaHeightRequest, opts ...grpc.CallOption) (*QueryLastZetaHeightResponse, error) TssHistory(ctx context.Context, in *QueryTssHistoryRequest, opts ...grpc.CallOption) (*QueryTssHistoryResponse, error) + CctxByStatus(ctx context.Context, in *QueryCctxByStatusRequest, opts ...grpc.CallOption) (*QueryCctxByStatusResponse, error) } type queryClient struct { @@ -3784,6 +3890,15 @@ func (c *queryClient) TssHistory(ctx context.Context, in *QueryTssHistoryRequest return out, nil } +func (c *queryClient) CctxByStatus(ctx context.Context, in *QueryCctxByStatusRequest, opts ...grpc.CallOption) (*QueryCctxByStatusResponse, error) { + out := new(QueryCctxByStatusResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Query/CctxByStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -3832,6 +3947,7 @@ type QueryServer interface { // Queries a list of lastMetaHeight items. LastZetaHeight(context.Context, *QueryLastZetaHeightRequest) (*QueryLastZetaHeightResponse, error) TssHistory(context.Context, *QueryTssHistoryRequest) (*QueryTssHistoryResponse, error) + CctxByStatus(context.Context, *QueryCctxByStatusRequest) (*QueryCctxByStatusResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -3919,6 +4035,9 @@ func (*UnimplementedQueryServer) LastZetaHeight(ctx context.Context, req *QueryL func (*UnimplementedQueryServer) TssHistory(ctx context.Context, req *QueryTssHistoryRequest) (*QueryTssHistoryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TssHistory not implemented") } +func (*UnimplementedQueryServer) CctxByStatus(ctx context.Context, req *QueryCctxByStatusRequest) (*QueryCctxByStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CctxByStatus not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -4410,6 +4529,24 @@ func _Query_TssHistory_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Query_CctxByStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCctxByStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CctxByStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.crosschain.Query/CctxByStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CctxByStatus(ctx, req.(*QueryCctxByStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.crosschain.Query", HandlerType: (*QueryServer)(nil), @@ -4522,11 +4659,80 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TssHistory", Handler: _Query_TssHistory_Handler, }, + { + MethodName: "CctxByStatus", + Handler: _Query_CctxByStatus_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "crosschain/query.proto", } +func (m *QueryCctxByStatusRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCctxByStatusRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCctxByStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryCctxByStatusResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCctxByStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCctxByStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CrossChainTx) > 0 { + for iNdEx := len(m.CrossChainTx) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CrossChainTx[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryTssHistoryRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -5265,6 +5471,11 @@ func (m *QueryGetTssAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l + if m.BitcoinChainId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BitcoinChainId)) + i-- + dAtA[i] = 0x10 + } if len(m.TssPubKey) > 0 { i -= len(m.TssPubKey) copy(dAtA[i:], m.TssPubKey) @@ -7022,6 +7233,33 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QueryCctxByStatusRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + return n +} + +func (m *QueryCctxByStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CrossChainTx) > 0 { + for _, e := range m.CrossChainTx { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryTssHistoryRequest) Size() (n int) { if m == nil { return 0 @@ -7312,6 +7550,9 @@ func (m *QueryGetTssAddressRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if m.BitcoinChainId != 0 { + n += 1 + sovQuery(uint64(m.BitcoinChainId)) + } return n } @@ -8084,6 +8325,159 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QueryCctxByStatusRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCctxByStatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCctxByStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= CctxStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCctxByStatusResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCctxByStatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCctxByStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CrossChainTx", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CrossChainTx = append(m.CrossChainTx, CrossChainTx{}) + if err := m.CrossChainTx[len(m.CrossChainTx)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryTssHistoryRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -9910,6 +10304,25 @@ func (m *QueryGetTssAddressRequest) Unmarshal(dAtA []byte) error { } m.TssPubKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BitcoinChainId", wireType) + } + m.BitcoinChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BitcoinChainId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/crosschain/types/query.pb.gw.go b/x/crosschain/types/query.pb.gw.go index ee6cee4368..b4a9373a3a 100644 --- a/x/crosschain/types/query.pb.gw.go +++ b/x/crosschain/types/query.pb.gw.go @@ -1157,6 +1157,66 @@ func local_request_Query_TssHistory_0(ctx context.Context, marshaler runtime.Mar } +func request_Query_CctxByStatus_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCctxByStatusRequest + var metadata runtime.ServerMetadata + + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["status"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status") + } + + e, err = runtime.Enum(val, CctxStatus_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status", err) + } + + protoReq.Status = CctxStatus(e) + + msg, err := client.CctxByStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CctxByStatus_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCctxByStatusRequest + var metadata runtime.ServerMetadata + + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["status"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status") + } + + e, err = runtime.Enum(val, CctxStatus_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status", err) + } + + protoReq.Status = CctxStatus(e) + + msg, err := server.CctxByStatus(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1784,6 +1844,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CctxByStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CctxByStatus_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CctxByStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2365,6 +2448,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CctxByStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CctxByStatus_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CctxByStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2422,6 +2525,8 @@ var ( pattern_Query_LastZetaHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "lastZetaHeight"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_TssHistory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "tssHistory"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CctxByStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "crosschain", "cctxbyStatus", "status"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -2478,4 +2583,6 @@ var ( forward_Query_LastZetaHeight_0 = runtime.ForwardResponseMessage forward_Query_TssHistory_0 = runtime.ForwardResponseMessage + + forward_Query_CctxByStatus_0 = runtime.ForwardResponseMessage ) diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index a5615c8450..0e789fcb04 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -1194,6 +1194,8 @@ type MsgVoteOnObservedInboundTx struct { CoinType common.CoinType `protobuf:"varint,12,opt,name=coin_type,json=coinType,proto3,enum=common.CoinType" json:"coin_type,omitempty"` TxOrigin string `protobuf:"bytes,13,opt,name=tx_origin,json=txOrigin,proto3" json:"tx_origin,omitempty"` Asset string `protobuf:"bytes,14,opt,name=asset,proto3" json:"asset,omitempty"` + // event index of the sent asset in the observed tx + EventIndex uint64 `protobuf:"varint,15,opt,name=event_index,json=eventIndex,proto3" json:"event_index,omitempty"` } func (m *MsgVoteOnObservedInboundTx) Reset() { *m = MsgVoteOnObservedInboundTx{} } @@ -1313,6 +1315,13 @@ func (m *MsgVoteOnObservedInboundTx) GetAsset() string { return "" } +func (m *MsgVoteOnObservedInboundTx) GetEventIndex() uint64 { + if m != nil { + return m.EventIndex + } + return 0 +} + type MsgVoteOnObservedInboundTxResponse struct { } @@ -1475,101 +1484,102 @@ func init() { func init() { proto.RegisterFile("crosschain/tx.proto", fileDescriptor_81d6d611190b7635) } var fileDescriptor_81d6d611190b7635 = []byte{ - // 1504 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6e, 0xdb, 0xc6, - 0x16, 0x36, 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 0xc1, 0x30, 0x7d, 0x64, 0xd5, 0x1a, 0xc8, 0x0c, 0x79, 0xaf, 0x38, 0xbc, 0xe8, 0x36, 0x1f, - 0x0d, 0x39, 0x85, 0xfc, 0xf3, 0x6a, 0xe5, 0x62, 0xcb, 0xf2, 0x6b, 0xf7, 0xf4, 0xb4, 0x38, 0xdd, - 0xc8, 0x31, 0x86, 0x68, 0x45, 0xa7, 0xad, 0x59, 0x33, 0x03, 0x34, 0xab, 0xb2, 0x02, 0x93, 0xdc, - 0x45, 0x56, 0xa3, 0xe2, 0x00, 0x05, 0xc6, 0xda, 0x8a, 0x38, 0xca, 0x75, 0xb8, 0xc0, 0x37, 0x44, - 0xa7, 0x09, 0xaf, 0xde, 0x2c, 0xf3, 0x3c, 0xc7, 0xd8, 0x65, 0x42, 0x58, 0xe5, 0xa6, 0x27, 0x13, - 0xb9, 0xdf, 0x64, 0xa2, 0x5f, 0x83, 0xb5, 0x1e, 0xa5, 0x9d, 0xb4, 0xc0, 0x5f, 0xa3, 0x6c, 0xe8, - 0x4a, 0xef, 0xdb, 0x09, 0xfa, 0x77, 0x40, 0xd4, 0xe4, 0x28, 0x70, 0x50, 0x28, 0xca, 0x5f, 0x50, - 0x91, 0x3b, 0x7c, 0x65, 0x76, 0x5c, 0xeb, 0x39, 0xce, 0xde, 0x12, 0xad, 0xaa, 0x41, 0x56, 0x84, - 0x38, 0x14, 0x77, 0x56, 0x42, 0x2b, 0xd7, 0x60, 0x3a, 0x5e, 0x8b, 0xb0, 0x8d, 0x73, 0x11, 0x31, - 0x97, 0x47, 0xee, 0x64, 0xf0, 0xcc, 0xbc, 0xd5, 0xe0, 0x19, 0x79, 0xe9, 0x23, 0x42, 0x2c, 0x97, - 0x87, 0x5e, 0x36, 0x62, 0x52, 0xb9, 0x02, 0x10, 0x85, 0x5c, 0x74, 0xb0, 0xcc, 0xed, 0xf4, 0x02, - 0xd1, 0xb8, 0xd7, 0xe1, 0x82, 0x17, 0x98, 0xe2, 0xee, 0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42, 0xb3, 0xd0, 0xfe, 0x27, 0x59, 0x74, 0xad, 0x57, 0x32, 0xec, 0xef, - 0xad, 0xdb, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x34, 0xdd, 0xf5, 0x5e, 0x3f, 0x13, 0x00, 0x00, + // 1516 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x5f, 0x6f, 0xdb, 0x54, + 0x14, 0xaf, 0x69, 0x9b, 0xc6, 0xa7, 0x4d, 0xff, 0xb8, 0xdd, 0xea, 0xb9, 0xeb, 0x9f, 0xb9, 0x6c, + 0x54, 0x68, 0x4d, 0xb6, 0x0e, 0xc4, 0x36, 0x40, 0x62, 0xad, 0xb6, 0xae, 0x8c, 0xb4, 0x93, 0x9b, + 0x81, 0xb4, 0x17, 0xcb, 0xb1, 0x6f, 0x1d, 0xab, 0xb1, 0x6f, 0xe4, 0x7b, 0x53, 0x25, 0x15, 0x12, + 0xd2, 0x24, 0x1e, 0x78, 0x43, 0x08, 0x09, 0xc4, 0x17, 0xe0, 0xab, 0xec, 0x8d, 0x89, 0x27, 0xc6, + 0xc3, 0x84, 0xb6, 0x4f, 0x00, 0x9f, 0x00, 0xf9, 0xde, 0x6b, 0x37, 0x4e, 0x9b, 0x7f, 0x9d, 0xf6, + 0x14, 0x9f, 0xe3, 0xfb, 0x3b, 0xff, 0xcf, 0x3d, 0xc7, 0x81, 0x59, 0x3b, 0xc4, 0x84, 0xd8, 0x15, + 0xcb, 0x0b, 0x0a, 0xb4, 0x91, 0xaf, 0x85, 0x98, 0x62, 0x65, 0xf1, 0x18, 0x51, 0x8b, 0xf1, 0xf2, + 0xec, 0x09, 0x87, 0x28, 0x7f, 0x72, 0x4e, 0x9b, 0xb5, 0xb1, 0xef, 0xe3, 0xa0, 0xc0, 0x7f, 0x38, + 0x46, 0x9b, 0x73, 0xb1, 0x8b, 0xd9, 0x63, 0x21, 0x7a, 0xe2, 0x5c, 0xfd, 0x27, 0x09, 0x94, 0x22, + 0x71, 0x8b, 0x9e, 0x1b, 0x5a, 0x14, 0x95, 0x08, 0x79, 0x50, 0x0f, 0x1c, 0xa2, 0xa8, 0x30, 0x66, + 0x87, 0xc8, 0xa2, 0x38, 0x54, 0xa5, 0x15, 0x69, 0x4d, 0x36, 0x62, 0x52, 0xb9, 0x04, 0x59, 0xa6, + 0xc4, 0xf4, 0x1c, 0xf5, 0xbd, 0x15, 0x69, 0x6d, 0xd8, 0x18, 0x63, 0xf4, 0x8e, 0xa3, 0x6c, 0x43, + 0xc6, 0xf2, 0x71, 0x3d, 0xa0, 0xea, 0x70, 0x84, 0xd9, 0x2c, 0x3c, 0x7f, 0xb5, 0x3c, 0xf4, 0xf7, + 0xab, 0xe5, 0x0f, 0x5c, 0x8f, 0x56, 0xea, 0xe5, 0xbc, 0x8d, 0xfd, 0x82, 0x8d, 0x89, 0x8f, 0x89, + 0xf8, 0x59, 0x27, 0xce, 0x61, 0x81, 0x36, 0x6b, 0x88, 0xe4, 0x9f, 0x78, 0x01, 0x35, 0x04, 0x5c, + 0xbf, 0x0c, 0xda, 0x69, 0x9b, 0x0c, 0x44, 0x6a, 0x38, 0x20, 0x48, 0xff, 0x57, 0x82, 0xd9, 0x22, + 0x71, 0xef, 0x39, 0x4e, 0x09, 0xef, 0x04, 0xa5, 0x46, 0x29, 0xb4, 0xec, 0x43, 0x14, 0x9e, 0xcf, + 0xe6, 0x79, 0x18, 0xa3, 0x0d, 0xb3, 0x62, 0x91, 0x0a, 0x37, 0xda, 0xc8, 0xd0, 0xc6, 0x43, 0x8b, + 0x54, 0x94, 0x75, 0x90, 0x6d, 0xec, 0x05, 0x66, 0x64, 0x9e, 0x3a, 0xb2, 0x22, 0xad, 0x4d, 0x6e, + 0x4c, 0xe7, 0x45, 0x40, 0xb7, 0xb0, 0x17, 0x94, 0x9a, 0x35, 0x64, 0x64, 0x6d, 0xf1, 0xa4, 0xac, + 0xc2, 0x68, 0x2d, 0xc4, 0xf8, 0x40, 0x1d, 0x5d, 0x91, 0xd6, 0xc6, 0x37, 0x72, 0xf1, 0xd1, 0xc7, + 0x11, 0xd3, 0xe0, 0xef, 0x94, 0x45, 0x80, 0x72, 0x15, 0xdb, 0x87, 0x5c, 0x5f, 0x86, 0xe9, 0x93, + 0x19, 0x87, 0xa9, 0xbc, 0x04, 0x59, 0xda, 0x30, 0xbd, 0xc0, 0x41, 0x0d, 0x75, 0x8c, 0x9b, 0x49, + 0x1b, 0x3b, 0x11, 0xa9, 0x2f, 0xc2, 0xc2, 0x19, 0x2e, 0x27, 0x21, 0xd9, 0x65, 0x11, 0x79, 0x52, + 0x73, 0x78, 0xbc, 0xee, 0x39, 0x4e, 0x88, 0x48, 0xb7, 0x2c, 0x2e, 0x02, 0x50, 0x42, 0xcc, 0x5a, + 0xbd, 0x7c, 0x88, 0x9a, 0x2c, 0x26, 0xb2, 0x21, 0x53, 0x42, 0x1e, 0x33, 0x86, 0x50, 0xd7, 0x2e, + 0x2f, 0x51, 0xf7, 0xa7, 0x04, 0x33, 0x45, 0xe2, 0x7e, 0x53, 0xf1, 0x28, 0xaa, 0x7a, 0x84, 0xde, + 0x37, 0xb6, 0x36, 0x6e, 0x74, 0xd1, 0xb6, 0x0a, 0x39, 0x14, 0xda, 0x1b, 0x37, 0x4c, 0x8b, 0x0b, + 0x12, 0x0a, 0x27, 0x18, 0x33, 0x36, 0xb6, 0x35, 0x49, 0xc3, 0xe9, 0x24, 0x29, 0x30, 0x12, 0x58, + 0x3e, 0x4f, 0x83, 0x6c, 0xb0, 0x67, 0xe5, 0x22, 0x64, 0x48, 0xd3, 0x2f, 0xe3, 0x2a, 0x8b, 0xb8, + 0x6c, 0x08, 0x4a, 0xd1, 0x20, 0xeb, 0x20, 0xdb, 0xf3, 0xad, 0x2a, 0x61, 0x11, 0xce, 0x19, 0x09, + 0xad, 0x2c, 0x80, 0xec, 0x5a, 0xc4, 0xac, 0x7a, 0xbe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, 0xe6, 0xf2, 0xc8, + 0x9d, 0x2c, 0x9e, 0x99, 0xb7, 0x5a, 0x3c, 0x23, 0x2f, 0x7d, 0x44, 0x88, 0xe5, 0xf2, 0xd0, 0xcb, + 0x46, 0x4c, 0x2a, 0x97, 0x01, 0xa2, 0x90, 0x8b, 0x0e, 0x96, 0xb9, 0x9d, 0x5e, 0x20, 0x1a, 0xf7, + 0x1a, 0x4c, 0x79, 0x81, 0x29, 0x66, 0x27, 0xef, 0x56, 0xde, 0x72, 0x39, 0x2f, 0x68, 0x6d, 0xd1, + 0xd4, 0x02, 0x32, 0xce, 0x4e, 0x24, 0x0b, 0x48, 0x3a, 0xaf, 0x13, 0x3d, 0x37, 0xce, 0x05, 0x90, + 0x69, 0xc3, 0xc4, 0xa1, 0xe7, 0x7a, 0x81, 0x9a, 0xe3, 0x06, 0xd1, 0xc6, 0x1e, 0xa3, 0xa3, 0xfb, + 0xcf, 0x22, 0x04, 0x51, 0x75, 0x92, 0xbd, 0xe0, 0x44, 0x54, 0x82, 0xe8, 0x08, 0x05, 0x54, 0xcc, + 0xf0, 0x29, 0x66, 0x00, 0x30, 0x16, 0x1f, 0xe3, 0xef, 0x83, 0xde, 0xb9, 0x06, 0x92, 0x52, 0xf9, + 0x41, 0x82, 0xc9, 0x22, 0x71, 0xf7, 0x11, 0xdd, 0xc5, 0x0e, 0x7a, 0x84, 0x9a, 0xdd, 0x36, 0xcd, + 0x02, 0xc8, 0x7c, 0x32, 0xee, 0x23, 0xca, 0x2a, 0x64, 0x7c, 0x63, 0x26, 0x59, 0x3e, 0xea, 0xe5, + 0x47, 0xec, 0x85, 0x71, 0x72, 0x46, 0xb9, 0x0e, 0x4a, 0xd4, 0x00, 0xc4, 0x73, 0x03, 0x14, 0x9a, + 0x62, 0xb7, 0x12, 0x77, 0xe6, 0x34, 0x25, 0x64, 0x9f, 0xbd, 0x10, 0x7c, 0x5d, 0x85, 0x8b, 0x69, + 0x53, 0x62, 0x2b, 0x37, 0xfe, 0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f, 0x13, 0xdd, 0xec, 0x2d, + 0xae, 0x0d, 0xa2, 0xdd, 0x19, 0x18, 0x12, 0x1b, 0xb0, 0xf9, 0xe8, 0xf9, 0xeb, 0x25, 0xe9, 0xc5, + 0xeb, 0x25, 0xe9, 0x9f, 0xd7, 0x4b, 0xd2, 0x8f, 0x6f, 0x96, 0x86, 0x5e, 0xbc, 0x59, 0x1a, 0xfa, + 0xeb, 0xcd, 0xd2, 0xd0, 0xd3, 0x9b, 0x2d, 0x83, 0x3e, 0x12, 0xba, 0xce, 0xff, 0x2f, 0x8b, 0xe5, + 0x17, 0x1a, 0x85, 0xd6, 0x7f, 0xd1, 0xa2, 0xb9, 0x5f, 0xce, 0xb0, 0xff, 0xbf, 0x6e, 0xfd, 0x1f, + 0x00, 0x00, 0xff, 0xff, 0x3f, 0x94, 0xa8, 0x99, 0x60, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2854,6 +2864,11 @@ func (m *MsgVoteOnObservedInboundTx) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l + if m.EventIndex != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.EventIndex)) + i-- + dAtA[i] = 0x78 + } if len(m.Asset) > 0 { i -= len(m.Asset) copy(dAtA[i:], m.Asset) @@ -3469,6 +3484,9 @@ func (m *MsgVoteOnObservedInboundTx) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.EventIndex != 0 { + n += 1 + sovTx(uint64(m.EventIndex)) + } return n } @@ -6355,6 +6373,25 @@ func (m *MsgVoteOnObservedInboundTx) Unmarshal(dAtA []byte) error { } m.Asset = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EventIndex", wireType) + } + m.EventIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EventIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/emissions/abci.go b/x/emissions/abci.go index 8e0fed774b..50f2f3daae 100644 --- a/x/emissions/abci.go +++ b/x/emissions/abci.go @@ -11,6 +11,7 @@ import ( ) func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) { + reservesFactor, bondFactor, durationFactor := keeper.GetBlockRewardComponents(ctx) blockRewards := reservesFactor.Mul(bondFactor).Mul(durationFactor) if blockRewards.IsZero() { diff --git a/x/fungible/client/cli/query.go b/x/fungible/client/cli/query.go index f0498d44b8..2fcda320d5 100644 --- a/x/fungible/client/cli/query.go +++ b/x/fungible/client/cli/query.go @@ -27,6 +27,7 @@ func GetQueryCmd(_ string) *cobra.Command { CmdGasStabilityPoolBalance(), CmdGasStabilityPoolBalances(), CmdSystemContract(), + CmdQueryCodeHash(), ) return cmd diff --git a/x/fungible/client/cli/query_code_hash.go b/x/fungible/client/cli/query_code_hash.go new file mode 100644 index 0000000000..460fd7a414 --- /dev/null +++ b/x/fungible/client/cli/query_code_hash.go @@ -0,0 +1,36 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func CmdQueryCodeHash() *cobra.Command { + cmd := &cobra.Command{ + Use: "code-hash [address]", + Short: "shows the code hash of an account", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.CodeHash(context.Background(), &types.QueryCodeHashRequest{ + Address: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/fungible/client/cli/tx.go b/x/fungible/client/cli/tx.go index 9b347fad35..64e0edda8f 100644 --- a/x/fungible/client/cli/tx.go +++ b/x/fungible/client/cli/tx.go @@ -19,9 +19,12 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand( + CmdDeploySystemContracts(), CmdDeployFungibleCoinZRC4(), CmdRemoveForeignCoin(), CmdUpdateZRC20LiquidityCap(), + CmdUpdateSystemContract(), + CmdUpdateContractBytecode(), ) return cmd diff --git a/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go b/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go index 3a82f7c75f..2697f7f293 100644 --- a/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go +++ b/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go @@ -17,7 +17,7 @@ func CmdDeployFungibleCoinZRC4() *cobra.Command { cmd := &cobra.Command{ Use: "deploy-fungible-coin-zrc-4 [erc-20] [foreign-chain] [decimals] [name] [symbol] [coin-type] [gas-limit]", Short: "Broadcast message DeployFungibleCoinZRC20", - Args: cobra.ExactArgs(6), + Args: cobra.ExactArgs(7), RunE: func(cmd *cobra.Command, args []string) (err error) { argERC20 := args[0] argForeignChain, err := strconv.ParseInt(args[1], 10, 32) diff --git a/x/fungible/client/cli/tx_deploy_system_contracts.go b/x/fungible/client/cli/tx_deploy_system_contracts.go new file mode 100644 index 0000000000..b8ed9dd9d2 --- /dev/null +++ b/x/fungible/client/cli/tx_deploy_system_contracts.go @@ -0,0 +1,34 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func CmdDeploySystemContracts() *cobra.Command { + cmd := &cobra.Command{ + Use: "deploy-system-contracts", + Short: "Broadcast message SystemContracts", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + msg := types.NewMsgDeploySystemContracts( + clientCtx.GetFromAddress().String(), + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/fungible/client/cli/tx_update_contract_bytecode.go b/x/fungible/client/cli/tx_update_contract_bytecode.go new file mode 100644 index 0000000000..8a67cf505a --- /dev/null +++ b/x/fungible/client/cli/tx_update_contract_bytecode.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func CmdUpdateContractBytecode() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-contract-bytecode [contract-address] [new-code-hash]", + Short: "Broadcast message UpdateContractBytecode", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateContractBytecode( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/fungible/client/cli/tx_update_update_system_contract.go b/x/fungible/client/cli/tx_update_update_system_contract.go new file mode 100644 index 0000000000..2f30a528e9 --- /dev/null +++ b/x/fungible/client/cli/tx_update_update_system_contract.go @@ -0,0 +1,35 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func CmdUpdateSystemContract() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-system-contract [contract-address] ", + Short: "Broadcast message UpdateSystemContract", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + fmt.Printf("CLI address: %s\n", clientCtx.GetFromAddress().String()) + msg := types.NewMsgUpdateSystemContract(clientCtx.GetFromAddress().String(), args[0]) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts.go deleted file mode 100644 index 8425f4e9a0..0000000000 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build !PRIVNET && !TESTNET && !MOCK_MAINNET -// +build !PRIVNET,!TESTNET,!MOCK_MAINNET - -package keeper - -import ( - "context" -) - -func (k Keeper) BlockOneDeploySystemContracts(_ context.Context) error { - return nil -} -func (k Keeper) TestUpdateSystemContractAddress(_ context.Context) error { - return nil -} -func (k Keeper) TestUpdateZRC20WithdrawFee(_ context.Context) error { - return nil -} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go deleted file mode 100644 index d5e3021e25..0000000000 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build MOCK_MAINNET -// +build MOCK_MAINNET - -package keeper - -import ( - "context" - "fmt" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/common" -) - -func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - // setup uniswap v2 factory - uniswapV2Factory, err := k.DeployUniswapV2Factory(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Factory") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("UniswapV2Factory", uniswapV2Factory.String()), - ), - ) - - // setup WZETA contract - wzeta, err := k.DeployWZETA(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployWZetaContract") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployWZetaContract", wzeta.String()), - ), - ) - - router, err := k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Router02") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployUniswapV2Router02", router.String()), - ), - ) - - connector, err := k.DeployConnectorZEVM(ctx, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployConnectorZEVM") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployConnectorZEVM", connector.String()), - ), - ) - ctx.Logger().Info("Deployed Connector ZEVM at " + connector.String()) - - SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) - if err != nil { - return sdkerrors.Wrapf(err, "failed to SystemContractAddress") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("SystemContractAddress", SystemContractAddress.String()), - ), - ) - - // set the system contract - system, _ := k.GetSystemContract(ctx) - system.SystemContract = SystemContractAddress.String() - k.SetSystemContract(ctx, system) - //err = k.SetGasPrice(ctx, big.NewInt(1337), big.NewInt(1)) - if err != nil { - return err - } - _, err = k.SetupChainGasCoinAndPool(ctx, common.EthChain().ChainId, "ETH", "ETH", 18, nil) - if err != nil { - return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.EthChain().ChainName)) - } - - _, err = k.SetupChainGasCoinAndPool(ctx, common.BscMainnetChain().ChainId, "BNB", "BNB", 18, nil) - if err != nil { - return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BscMainnetChain().ChainName)) - } - _, err = k.SetupChainGasCoinAndPool(ctx, common.BtcMainnetChain().ChainId, "BTC", "BTC", 8, nil) - if err != nil { - return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BtcMainnetChain().ChainName)) - } - return nil -} -func (k Keeper) TestUpdateSystemContractAddress(_ context.Context) error { - return nil -} -func (k Keeper) TestUpdateZRC20WithdrawFee(_ context.Context) error { - return nil -} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go deleted file mode 100644 index cbcedd747b..0000000000 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go +++ /dev/null @@ -1,166 +0,0 @@ -//go:build PRIVNET - -package keeper - -import ( - "context" - "fmt" - "math/big" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/common" - "github.com/zeta-chain/zetacore/x/fungible/types" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" -) - -// This is for privnet/testnet only -func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - // setup uniswap v2 factory - uniswapV2Factory, err := k.DeployUniswapV2Factory(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Factory") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("UniswapV2Factory", uniswapV2Factory.String()), - ), - ) - - // setup WZETA contract - wzeta, err := k.DeployWZETA(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployWZetaContract") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployWZetaContract", wzeta.String()), - ), - ) - - router, err := k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Router02") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployUniswapV2Router02", router.String()), - ), - ) - - connector, err := k.DeployConnectorZEVM(ctx, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployConnectorZEVM") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployConnectorZEVM", connector.String()), - ), - ) - ctx.Logger().Info("Deployed Connector ZEVM at " + connector.String()) - - SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) - if err != nil { - return sdkerrors.Wrapf(err, "failed to SystemContractAddress") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("SystemContractAddress", SystemContractAddress.String()), - ), - ) - - // set the system contract - system, _ := k.GetSystemContract(ctx) - system.SystemContract = SystemContractAddress.String() - // FIXME: remove unnecessary SetGasPrice and setupChainGasCoinAndPool - k.SetSystemContract(ctx, system) - //err = k.SetGasPrice(ctx, big.NewInt(1337), big.NewInt(1)) - if err != nil { - return err - } - - ETHZRC20Addr, err := k.SetupChainGasCoinAndPool(ctx, common.GoerliChain().ChainId, "ETH", "gETH", 18, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - ctx.Logger().Info("Deployed ETH ZRC20 at " + ETHZRC20Addr.String()) - - BTCZRC20Addr, err := k.SetupChainGasCoinAndPool(ctx, common.BtcRegtestChain().ChainId, "BTC", "tBTC", 8, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - ctx.Logger().Info("Deployed BTC ZRC20 at " + BTCZRC20Addr.String()) - - //FIXME: clean up and config the above based on localnet/testnet/mainnet - - // for localnet only: USDT ZRC20 - USDTAddr := "0xff3135df4F2775f4091b81f4c7B6359CfA07862a" - USDTZRC20Addr, err := k.DeployZRC20Contract(ctx, "USDT", "USDT", uint8(6), common.GoerliChain().ChainId, common.CoinType_ERC20, USDTAddr, big.NewInt(90_000)) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployZRC20Contract USDT") - } - ctx.Logger().Info("Deployed USDT ZRC20 at " + USDTZRC20Addr.String()) - // for localnet only: ZEVM Swap App - //ZEVMSwapAddress, err := k.DeployZEVMSwapApp(ctx, router, SystemContractAddress) - //if err != nil { - // return sdkerrors.Wrapf(err, "failed to deploy ZEVMSwapApp") - //} - //ctx.Logger().Info("Deployed ZEVM Swap App at " + ZEVMSwapAddress.String()) - fmt.Println("Successfully deployed contracts") - return nil -} - -func (k Keeper) TestUpdateSystemContractAddress(goCtx context.Context) error { - ctx := sdk.UnwrapSDKContext(goCtx) - msgServer := NewMsgServerImpl(k) - - wzeta, err := k.GetWZetaContractAddress(ctx) - if err != nil { - return sdkerrors.Wrap(err, "failed to GetWZetaContractAddress") - } - uniswapV2Factory, err := k.GetUniswapV2FactoryAddress(ctx) - if err != nil { - return sdkerrors.Wrap(err, "failed to GetUniswapv2FacotryAddress") - } - router, err := k.GetUniswapV2Router02Address(ctx) - if err != nil { - return sdkerrors.Wrap(err, "failed to GetUniswapV2Router02Address") - } - - SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeploySystemContract") - } - creator := k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group1) - msg := types.NewMsgUpdateSystemContract(creator, SystemContractAddress.Hex()) - _, err = msgServer.UpdateSystemContract(ctx, msg) - k.Logger(ctx).Info("System contract updated", "new address", SystemContractAddress.String()) - return err -} - -func (k Keeper) TestUpdateZRC20WithdrawFee(goCtx context.Context) error { - ctx := sdk.UnwrapSDKContext(goCtx) - msgServer := NewMsgServerImpl(k) - - foreignCoins := k.GetAllForeignCoins(ctx) - creator := k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group1) - - for _, foreignCoin := range foreignCoins { - msg := types.NewMsgUpdateZRC20WithdrawFee( - creator, - foreignCoin.Zrc20ContractAddress, - sdk.NewUint(uint64(foreignCoin.ForeignChainId)), - math.Uint{}, - ) - _, err := msgServer.UpdateZRC20WithdrawFee(ctx, msg) - if err != nil { - return err - } - } - - return nil -} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go deleted file mode 100644 index 5c19164ba0..0000000000 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go +++ /dev/null @@ -1,106 +0,0 @@ -//go:build TESTNET - -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/common" -) - -// This is for privnet/testnet only -func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - // setup uniswap v2 factory - uniswapV2Factory, err := k.DeployUniswapV2Factory(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Factory") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("UniswapV2Factory", uniswapV2Factory.String()), - ), - ) - - // setup WZETA contract - wzeta, err := k.DeployWZETA(ctx) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployWZetaContract") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployWZetaContract", wzeta.String()), - ), - ) - - router, err := k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Router02") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployUniswapV2Router02", router.String()), - ), - ) - - connector, err := k.DeployConnectorZEVM(ctx, wzeta) - if err != nil { - return sdkerrors.Wrapf(err, "failed to DeployConnectorZEVM") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("DeployConnectorZEVM", connector.String()), - ), - ) - ctx.Logger().Info("Deployed Connector ZEVM at " + connector.String()) - - SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) - if err != nil { - return sdkerrors.Wrapf(err, "failed to SystemContractAddress") - } - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("SystemContractAddress", SystemContractAddress.String()), - ), - ) - - // set the system contract - system, _ := k.GetSystemContract(ctx) - system.SystemContract = SystemContractAddress.String() - // FIXME: remove unnecessary SetGasPrice and setupChainGasCoinAndPool - k.SetSystemContract(ctx, system) - //err = k.SetGasPrice(ctx, big.NewInt(1337), big.NewInt(1)) - if err != nil { - return err - } - _, err = k.SetupChainGasCoinAndPool(ctx, common.GoerliChain().ChainId, "ETH", "gETH", 18, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - - _, err = k.SetupChainGasCoinAndPool(ctx, common.BscTestnetChain().ChainId, "BNB", "tBNB", 18, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - _, err = k.SetupChainGasCoinAndPool(ctx, common.MumbaiChain().ChainId, "MATIC", "tMATIC", 18, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - _, err = k.SetupChainGasCoinAndPool(ctx, common.BtcTestNetChain().ChainId, "BTC", "tBTC", 8, nil) - if err != nil { - return sdkerrors.Wrapf(err, "failed to setupChainGasCoinAndPool") - } - - return nil -} - -func (k Keeper) TestUpdateSystemContractAddress(goCtx context.Context) error { - return nil -} - -func (k Keeper) TestUpdateZRC20WithdrawFee(goCtx context.Context) error { - return nil -} diff --git a/x/fungible/keeper/deposits.go b/x/fungible/keeper/deposits.go index fa197a953b..832613aa2c 100644 --- a/x/fungible/keeper/deposits.go +++ b/x/fungible/keeper/deposits.go @@ -49,6 +49,11 @@ func (k Keeper) ZRC20DepositAndCallContract( } ZRC20Contract = eth.HexToAddress(coin.Zrc20ContractAddress) + // check if foreign coin is paused + if coin.Paused { + return nil, false, types.ErrPausedZRC20 + } + // check foreign coins cap if it has a cap if !coin.LiquidityCap.IsNil() && !coin.LiquidityCap.IsZero() { liquidityCap := coin.LiquidityCap.BigInt() diff --git a/x/fungible/keeper/deposits_test.go b/x/fungible/keeper/deposits_test.go index 2e357cd42c..4131a1e00d 100644 --- a/x/fungible/keeper/deposits_test.go +++ b/x/fungible/keeper/deposits_test.go @@ -153,6 +153,38 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { require.Equal(t, big.NewInt(500), balance) }) + t.Run("should fail if coin paused", func(t *testing.T) { + // setup gas coin + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + chainList := common.DefaultChainsList() + chain := chainList[0] + + // deploy the system contracts + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chain.ChainId, "foobar", "foobar") + + // pause the coin + coin, found := k.GetForeignCoins(ctx, zrc20.String()) + require.True(t, found) + coin.Paused = true + k.SetForeignCoins(ctx, coin) + + to := sample.EthAddress() + _, _, err := k.ZRC20DepositAndCallContract( + ctx, + sample.EthAddress().Bytes(), + to, + big.NewInt(42), + chain, + []byte{}, + common.CoinType_Gas, + sample.EthAddress().String(), + ) + require.ErrorIs(t, err, types.ErrPausedZRC20) + }) + t.Run("should fail if liquidity cap reached", func(t *testing.T) { // setup gas coin k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index f0683deb60..0555c0cb95 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -101,6 +101,12 @@ func (k Keeper) DeployZRC20Contract( if chain == nil { return common.Address{}, cosmoserrors.Wrapf(zetaObserverTypes.ErrSupportedChains, "chain %s not found", chainStr) } + // Check if Contract has already been deployed for Asset + _, found := k.GetForeignCoinFromAsset(ctx, erc20Contract, chainID) + if found { + return common.Address{}, types.ErrForeignCoinAlreadyExist + } + system, found := k.GetSystemContract(ctx) if !found { return common.Address{}, cosmoserrors.Wrapf(types.ErrSystemContractNotFound, "system contract not found") @@ -118,7 +124,6 @@ func (k Keeper) DeployZRC20Contract( if err != nil { return common.Address{}, cosmoserrors.Wrapf(types.ErrABIPack, "failed to deploy ZRC20 contract: %s, %s", name, err.Error()) } - coin, _ := k.GetForeignCoins(ctx, contractAddr.Hex()) coin.CoinType = coinType coin.Name = name @@ -571,7 +576,7 @@ func (k Keeper) CallEVM( k.Logger(ctx).Debug("calling EVM", "from", from, "contract", contract, "value", value, "method", method) resp, err := k.CallEVMWithData(ctx, from, &contract, data, commit, noEthereumTxEvent, value, gasLimit) if err != nil { - errMes := fmt.Sprintf("contract call failed: method '%s', contract '%s'", method, contract.Hex()) + errMes := fmt.Sprintf("contract call failed: method '%s', contract '%s', args: %v", method, contract.Hex(), args) // if it is a revert error then add the revert reason to the error message revertErr, ok := err.(*evmtypes.RevertError) diff --git a/x/fungible/keeper/gas_coin_and_pool.go b/x/fungible/keeper/gas_coin_and_pool.go index d33c3ddec6..7540b90f69 100644 --- a/x/fungible/keeper/gas_coin_and_pool.go +++ b/x/fungible/keeper/gas_coin_and_pool.go @@ -34,6 +34,12 @@ func (k Keeper) SetupChainGasCoinAndPool( transferGasLimit := gasLimit + // Check if gas coin already exists + _, found := k.GetGasCoinForForeignCoin(ctx, chainID) + if found { + return ethcommon.Address{}, types.ErrForeignCoinAlreadyExist + } + // default values if transferGasLimit == nil { transferGasLimit = big.NewInt(21_000) diff --git a/x/fungible/keeper/grpc_query_code_hash.go b/x/fungible/keeper/grpc_query_code_hash.go new file mode 100644 index 0000000000..78fa60e3be --- /dev/null +++ b/x/fungible/keeper/grpc_query_code_hash.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + + "github.com/zeta-chain/zetacore/x/fungible/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// CodeHash returns the code hash of an account if it exists +func (k Keeper) CodeHash(c context.Context, req *types.QueryCodeHashRequest) (*types.QueryCodeHashResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + // convert address to hex + if !ethcommon.IsHexAddress(req.Address) { + return nil, status.Error(codes.InvalidArgument, "invalid address") + } + address := ethcommon.HexToAddress(req.Address) + + // fetch account + ctx := sdk.UnwrapSDKContext(c) + acc := k.evmKeeper.GetAccount(ctx, address) + if acc == nil { + return nil, status.Error(codes.NotFound, "account not found") + } + if !acc.IsContract() { + return nil, status.Error(codes.NotFound, "account is not a contract") + } + + // convert code hash to hex + codeHash := ethcommon.BytesToHash(acc.CodeHash) + + return &types.QueryCodeHashResponse{CodeHash: codeHash.Hex()}, nil +} diff --git a/x/fungible/keeper/grpc_query_code_hash_test.go b/x/fungible/keeper/grpc_query_code_hash_test.go new file mode 100644 index 0000000000..e2359dc530 --- /dev/null +++ b/x/fungible/keeper/grpc_query_code_hash_test.go @@ -0,0 +1,60 @@ +package keeper_test + +import ( + "testing" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestKeeper_CodeHash(t *testing.T) { + t.Run("should return code hash", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + wzeta, _, _, _, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + acc := sdkk.EvmKeeper.GetAccount(ctx, wzeta) + require.NotNil(t, acc) + require.NotNil(t, acc.CodeHash) + + res, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ + Address: wzeta.Hex(), + }) + require.NoError(t, err) + require.Equal(t, ethcommon.BytesToHash(acc.CodeHash).Hex(), res.CodeHash) + }) + + t.Run("should return error if address is invalid", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + + _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ + Address: "invalid", + }) + require.Error(t, err) + require.ErrorContains(t, err, "invalid address") + }) + + t.Run("should return error if account not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + + _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ + Address: sample.EthAddress().Hex(), + }) + require.Error(t, err) + require.ErrorContains(t, err, "account not found") + }) + + t.Run("should return error if account is not a contract", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + _, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ + Address: types.ModuleAddressEVM.Hex(), + }) + require.Error(t, err) + require.ErrorContains(t, err, "account is not a contract") + }) +} diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go index 95426c9437..1e64419f1a 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go @@ -154,4 +154,40 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { require.Error(t, err) require.ErrorIs(t, err, observertypes.ErrSupportedChains) }) + + t.Run("should not deploy an existing gas or erc20 contract", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.FungibleKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + admin := sample.AccAddress() + setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) + chainID := getValidChainID(t) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + + deployMsg := types.NewMsgDeployFungibleCoinZRC20( + admin, + sample.EthAddress().Hex(), + chainID, + 8, + "foo", + "foo", + common.CoinType_Gas, + 1000000, + ) + + // Attempt to deploy the same gas token twice should result in error + _, err := keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) + require.NoError(t, err) + _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) + + // Similar to above, redeploying existing erc20 should also fail + deployMsg.CoinType = common.CoinType_ERC20 + _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) + require.NoError(t, err) + _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) + }) } diff --git a/x/fungible/keeper/msg_server_deploy_system_contract.go b/x/fungible/keeper/msg_server_deploy_system_contract.go new file mode 100644 index 0000000000..284e6b5759 --- /dev/null +++ b/x/fungible/keeper/msg_server_deploy_system_contract.go @@ -0,0 +1,77 @@ +package keeper + +import ( + "context" + + cosmoserror "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/zeta-chain/zetacore/x/fungible/types" + zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +// DeploySystemContracts deploy new instances of the system contracts +func (k msgServer) DeploySystemContracts(goCtx context.Context, msg *types.MsgDeploySystemContracts) (*types.MsgDeploySystemContractsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_group2) { + return nil, cosmoserror.Wrap(sdkerrors.ErrUnauthorized, "System contract deployment can only be executed by the correct policy account") + } + + // uniswap v2 factory + factory, err := k.DeployUniswapV2Factory(ctx) + if err != nil { + return nil, cosmoserror.Wrapf(err, "failed to deploy UniswapV2Factory") + } + + // wzeta contract + wzeta, err := k.DeployWZETA(ctx) + if err != nil { + return nil, cosmoserror.Wrapf(err, "failed to DeployWZetaContract") + } + + // uniswap v2 router + router, err := k.DeployUniswapV2Router02(ctx, factory, wzeta) + if err != nil { + return nil, cosmoserror.Wrapf(err, "failed to deploy UniswapV2Router02") + } + + // connector zevm + connector, err := k.DeployConnectorZEVM(ctx, wzeta) + if err != nil { + return nil, cosmoserror.Wrapf(err, "failed to deploy ConnectorZEVM") + } + + // system contract + systemContract, err := k.DeploySystemContract(ctx, wzeta, factory, router) + if err != nil { + return nil, cosmoserror.Wrapf(err, "failed to deploy SystemContract") + } + + err = ctx.EventManager().EmitTypedEvent( + &types.EventSystemContractsDeployed{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgDeploySystemContracts{}), + UniswapV2Factory: factory.Hex(), + Wzeta: wzeta.Hex(), + UniswapV2Router: router.Hex(), + ConnectorZevm: connector.Hex(), + SystemContract: systemContract.Hex(), + Signer: msg.Creator, + }, + ) + if err != nil { + k.Logger(ctx).Error("failed to emit event", + "event", "EventSystemContractsDeployed", + "error", err.Error(), + ) + return nil, cosmoserror.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) + } + + return &types.MsgDeploySystemContractsResponse{ + UniswapV2Factory: factory.Hex(), + Wzeta: wzeta.Hex(), + UniswapV2Router: router.Hex(), + ConnectorZEVM: connector.Hex(), + SystemContract: systemContract.Hex(), + }, nil +} diff --git a/x/fungible/keeper/msg_server_deploy_system_contract_test.go b/x/fungible/keeper/msg_server_deploy_system_contract_test.go new file mode 100644 index 0000000000..86b9745021 --- /dev/null +++ b/x/fungible/keeper/msg_server_deploy_system_contract_test.go @@ -0,0 +1,68 @@ +package keeper_test + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/mock" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/keeper" + "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestMsgServer_DeploySystemContracts(t *testing.T) { + t.Run("admin can deploy system contracts", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.FungibleKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + admin := sample.AccAddress() + setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) + + res, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(admin)) + require.NoError(t, err) + require.NotNil(t, res) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.UniswapV2Factory)) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.Wzeta)) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.UniswapV2Router)) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.ConnectorZEVM)) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.SystemContract)) + }) + + t.Run("non-admin cannot deploy system contracts", func(t *testing.T) { + k, ctx, _, zk := keepertest.FungibleKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + nonadmin := sample.AccAddress() + setAdminPolicies(ctx, zk, nonadmin, observertypes.Policy_Type_group1) + + _, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(nonadmin)) + require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) + }) + + t.Run("should fail if contract deployment fails", func(t *testing.T) { + k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ + UseEVMMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + admin := sample.AccAddress() + setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) + + mockEVMKeeper := keepertest.GetFungibleEVMMock(t, k) + mockEVMKeeper.On( + "EstimateGas", + mock.Anything, + mock.Anything, + ).Return(nil, errors.New("failed to estimate gas")) + + _, err := msgServer.DeploySystemContracts(ctx, types.NewMsgDeploySystemContracts(admin)) + require.Error(t, err) + require.Contains(t, err.Error(), "failed to deploy") + }) +} diff --git a/x/fungible/keeper/msg_server_update_contract_bytecode.go b/x/fungible/keeper/msg_server_update_contract_bytecode.go index 5d5e7c7950..5c2d328bbd 100644 --- a/x/fungible/keeper/msg_server_update_contract_bytecode.go +++ b/x/fungible/keeper/msg_server_update_contract_bytecode.go @@ -4,7 +4,6 @@ import ( "context" cosmoserror "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" @@ -48,19 +47,9 @@ func (k msgServer) UpdateContractBytecode(goCtx context.Context, msg *types.MsgU } } - // fetch the account of the new bytecode - if !ethcommon.IsHexAddress(msg.NewBytecodeAddress) { - return nil, cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", msg.NewBytecodeAddress) - } - newBytecodeAddress := ethcommon.HexToAddress(msg.NewBytecodeAddress) - newBytecodeAcct := k.evmKeeper.GetAccount(ctx, newBytecodeAddress) - if newBytecodeAcct == nil { - return nil, cosmoserror.Wrapf(types.ErrContractNotFound, "contract (%s) not found", newBytecodeAddress.Hex()) - } - // set the new CodeHash to the account - previousCodeHash := acct.CodeHash - acct.CodeHash = newBytecodeAcct.CodeHash + oldCodeHash := acct.CodeHash + acct.CodeHash = ethcommon.HexToHash(msg.NewCodeHash).Bytes() err := k.evmKeeper.SetAccount(ctx, contractAddress, *acct) if err != nil { return nil, cosmoserror.Wrapf( @@ -70,14 +59,20 @@ func (k msgServer) UpdateContractBytecode(goCtx context.Context, msg *types.MsgU err.Error(), ) } - k.Logger(ctx).Info( - "updated contract bytecode", - "contract", contractAddress.Hex(), - "oldCodeHash", string(previousCodeHash), - "newCodeHash", string(acct.CodeHash), + + err = ctx.EventManager().EmitTypedEvent( + &types.EventBytecodeUpdated{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUpdateContractBytecode{}), + ContractAddress: msg.ContractAddress, + OldBytecodeHash: ethcommon.BytesToHash(oldCodeHash).Hex(), + NewBytecodeHash: msg.NewCodeHash, + Signer: msg.Creator, + }, ) + if err != nil { + k.Logger(ctx).Error("failed to emit event", "error", err.Error()) + return nil, cosmoserror.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) + } - return &types.MsgUpdateContractBytecodeResponse{ - NewBytecodeHash: acct.CodeHash, - }, nil + return &types.MsgUpdateContractBytecodeResponse{}, nil } diff --git a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go index 57f1c8b931..cb8e894eb0 100644 --- a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go +++ b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go @@ -5,6 +5,8 @@ import ( "math/big" "testing" + ethcommon "github.com/ethereum/go-ethereum/common" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/evmos/ethermint/x/evm/statedb" @@ -29,6 +31,14 @@ func setAdminPolicies(ctx sdk.Context, zk keepertest.ZetaKeepers, admin string, }) } +func codeHashFromAddress(t *testing.T, ctx sdk.Context, k *keeper.Keeper, contractAddr string) string { + res, err := k.CodeHash(ctx, &types.QueryCodeHashRequest{ + Address: contractAddr, + }) + require.NoError(t, err) + return res.CodeHash +} + func TestKeeper_UpdateContractBytecode(t *testing.T) { t.Run("can update the bytecode from another contract", func(t *testing.T) { k, ctx, sdkk, zk := keepertest.FungibleKeeper(t) @@ -92,18 +102,19 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { big.NewInt(90_000), ) require.NoError(t, err) + codeHash := codeHashFromAddress(t, ctx, k, newCodeAddress.Hex()) // update the bytecode - res, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( + _, err = msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - zrc20, - newCodeAddress, + zrc20.Hex(), + codeHash, )) require.NoError(t, err) // check the returned new bytecode hash matches the one in the account acct := sdkk.EvmKeeper.GetAccount(ctx, zrc20) - require.Equal(t, acct.CodeHash, res.NewBytecodeHash) + require.Equal(t, acct.CodeHash, ethcommon.HexToHash(codeHash).Bytes()) // check the state // balances and total supply should remain @@ -134,11 +145,12 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { "gamma", big.NewInt(90_000), ) + codeHash = codeHashFromAddress(t, ctx, k, newCodeAddress.Hex()) require.NoError(t, err) _, err = msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - zrc20, - newCodeAddress, + zrc20.Hex(), + codeHash, )) require.NoError(t, err) balance, err = k.BalanceOfZRC4(ctx, zrc20, addr1) @@ -161,6 +173,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // deploy a connector setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) wzeta, _, _, oldConnector, _ := deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + codeHash := codeHashFromAddress(t, ctx, k, oldConnector.Hex()) // deploy a new connector that will become official connector newConnector, err := k.DeployConnectorZEVM(ctx, wzeta) @@ -171,8 +184,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // can update the bytecode of the new connector with the old connector contract _, err = msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - newConnector, - oldConnector, + newConnector.Hex(), + codeHash, )) require.NoError(t, err) }) @@ -183,8 +196,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( sample.AccAddress(), - sample.EthAddress(), - sample.EthAddress(), + sample.EthAddress().Hex(), + sample.Hash().Hex(), )) require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) @@ -197,9 +210,9 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) _, err := msgServer.UpdateContractBytecode(ctx, &types.MsgUpdateContractBytecode{ - Creator: admin, - ContractAddress: "invalid", - NewBytecodeAddress: sample.EthAddress().Hex(), + Creator: admin, + ContractAddress: "invalid", + NewCodeHash: sample.Hash().Hex(), }) require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) @@ -222,8 +235,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - contractAddr, - sample.EthAddress(), + contractAddr.Hex(), + sample.Hash().Hex(), )) require.ErrorIs(t, err, types.ErrContractNotFound) @@ -242,8 +255,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // can't update the bytecode of the wzeta contract _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - wzeta, - sample.EthAddress(), + wzeta.Hex(), + sample.Hash().Hex(), )) require.ErrorIs(t, err, types.ErrInvalidContract) }) @@ -263,82 +276,12 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { // can't update the bytecode of the wzeta contract _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - connector, - sample.EthAddress(), + connector.Hex(), + sample.Hash().Hex(), )) require.ErrorIs(t, err, types.ErrSystemContractNotFound) }) - t.Run("should fail if invalid bytecode address", func(t *testing.T) { - k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ - UseEVMMock: true, - }) - msgServer := keeper.NewMsgServerImpl(*k) - mockEVMKeeper := keepertest.GetFungibleEVMMock(t, k) - admin := sample.AccAddress() - setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) - - // set the contract as the connector - contract := sample.EthAddress() - k.SetSystemContract(ctx, types.SystemContract{ - ConnectorZevm: contract.Hex(), - }) - - mockEVMKeeper.On( - "GetAccount", - mock.Anything, - mock.Anything, - ).Return(&statedb.Account{}) - - _, err := msgServer.UpdateContractBytecode(ctx, &types.MsgUpdateContractBytecode{ - Creator: admin, - ContractAddress: contract.Hex(), - NewBytecodeAddress: "invalid", - }) - - require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) - - mockEVMKeeper.AssertExpectations(t) - }) - - t.Run("should fail if can't get new bytecode account", func(t *testing.T) { - k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ - UseEVMMock: true, - }) - msgServer := keeper.NewMsgServerImpl(*k) - mockEVMKeeper := keepertest.GetFungibleEVMMock(t, k) - admin := sample.AccAddress() - setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) - contractAddr := sample.EthAddress() - newBytecodeAddr := sample.EthAddress() - - // set the contract as the connector - k.SetSystemContract(ctx, types.SystemContract{ - ConnectorZevm: contractAddr.String(), - }) - - mockEVMKeeper.On( - "GetAccount", - mock.Anything, - contractAddr, - ).Return(&statedb.Account{}) - - mockEVMKeeper.On( - "GetAccount", - mock.Anything, - newBytecodeAddr, - ).Return(nil) - - _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( - admin, - contractAddr, - newBytecodeAddr, - )) - require.ErrorIs(t, err, types.ErrContractNotFound) - - mockEVMKeeper.AssertExpectations(t) - }) - t.Run("should fail if can't set account with new bytecode", func(t *testing.T) { k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ UseEVMMock: true, @@ -348,7 +291,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { admin := sample.AccAddress() setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) contractAddr := sample.EthAddress() - newBytecodeAddr := sample.EthAddress() + newCodeHash := sample.Hash().Hex() // set the contract as the connector k.SetSystemContract(ctx, types.SystemContract{ @@ -361,12 +304,6 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { contractAddr, ).Return(&statedb.Account{}) - mockEVMKeeper.On( - "GetAccount", - mock.Anything, - newBytecodeAddr, - ).Return(&statedb.Account{}) - mockEVMKeeper.On( "SetAccount", mock.Anything, @@ -376,8 +313,8 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { _, err := msgServer.UpdateContractBytecode(ctx, types.NewMsgUpdateContractBytecode( admin, - contractAddr, - newBytecodeAddr, + contractAddr.Hex(), + newCodeHash, )) require.ErrorIs(t, err, types.ErrSetBytecode) diff --git a/x/fungible/module.go b/x/fungible/module.go index 7ea3ff45d0..e66b28f1e8 100644 --- a/x/fungible/module.go +++ b/x/fungible/module.go @@ -176,33 +176,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock executes all ABCI BeginBlock logic respective to the fungible module. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { - //TODO : moved to init-genesis - // https://github.com/zeta-chain/node/issues/866 - if ctx.BlockHeight() == 1 { - err := am.keeper.BlockOneDeploySystemContracts(sdk.WrapSDKContext(ctx)) - if err != nil { - ctx.Logger().Error("Unable To deploy contracts", "err", err.Error()) - } - } - - if ctx.BlockHeight() == 20 { - err := am.keeper.TestUpdateSystemContractAddress(sdk.WrapSDKContext(ctx)) - if err != nil { - ctx.Logger().Error("Unable To update system contracts", "err", err.Error()) - } else { - ctx.Logger().Info("System contract updated") - } - } - if ctx.BlockHeight() == 25 { - err := am.keeper.TestUpdateZRC20WithdrawFee(sdk.WrapSDKContext(ctx)) - if err != nil { - ctx.Logger().Error("Unable To update zrc20 withdraw fee", "err", err.Error()) - } else { - ctx.Logger().Info("zrc20 withdraw fee updated") - } - } -} +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock executes all ABCI EndBlock logic respective to the fungible module. It // returns no validator updates. diff --git a/x/fungible/types/codec.go b/x/fungible/types/codec.go index 47bbfee990..ac7fc91429 100644 --- a/x/fungible/types/codec.go +++ b/x/fungible/types/codec.go @@ -9,6 +9,7 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgDeployFungibleCoinZRC20{}, "fungible/DeployFungibleCoinZRC20", nil) + cdc.RegisterConcrete(&MsgDeploySystemContracts{}, "fungible/MsgDeploySystemContracts", nil) cdc.RegisterConcrete(&MsgRemoveForeignCoin{}, "fungible/RemoveForeignCoin", nil) cdc.RegisterConcrete(&MsgUpdateSystemContract{}, "fungible/UpdateSystemContract", nil) cdc.RegisterConcrete(&MsgUpdateZRC20WithdrawFee{}, "fungible/UpdateZRC20WithdrawFee", nil) @@ -20,6 +21,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgDeployFungibleCoinZRC20{}, + &MsgDeploySystemContracts{}, &MsgRemoveForeignCoin{}, &MsgUpdateSystemContract{}, &MsgUpdateZRC20WithdrawFee{}, diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index 8ab68525a3..2652442b4a 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -8,24 +8,16 @@ import ( // x/fungible module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") ErrABIPack = sdkerrors.Register(ModuleName, 1101, "abi pack error") ErrABIGet = sdkerrors.Register(ModuleName, 1102, "abi get error") - ErrUnexpectedEvent = sdkerrors.Register(ModuleName, 1103, "unexpected event") ErrABIUnpack = sdkerrors.Register(ModuleName, 1104, "abi unpack error") - ErrBlanceQuery = sdkerrors.Register(ModuleName, 1105, "balance query error") - ErrBalanceInvariance = sdkerrors.Register(ModuleName, 1106, "balance invariance error") ErrContractNotFound = sdkerrors.Register(ModuleName, 1107, "contract not found") - ErrChainNotFound = sdkerrors.Register(ModuleName, 1108, "chain not found") ErrContractCall = sdkerrors.Register(ModuleName, 1109, "contract call error") ErrSystemContractNotFound = sdkerrors.Register(ModuleName, 1110, "system contract not found") ErrInvalidAddress = sdkerrors.Register(ModuleName, 1111, "invalid address") ErrStateVariableNotFound = sdkerrors.Register(ModuleName, 1112, "state variable not found") - ErrDeployContract = sdkerrors.Register(ModuleName, 1113, "deploy contract error") ErrEmitEvent = sdkerrors.Register(ModuleName, 1114, "emit event error") ErrInvalidDecimals = sdkerrors.Register(ModuleName, 1115, "invalid decimals") - ErrGasPriceNotFound = sdkerrors.Register(ModuleName, 1116, "gas price not found") - ErrUpdateNonce = sdkerrors.Register(ModuleName, 1117, "update nonce error") ErrInvalidGasLimit = sdkerrors.Register(ModuleName, 1118, "invalid gas limit") ErrSetBytecode = sdkerrors.Register(ModuleName, 1119, "set bytecode error") ErrInvalidContract = sdkerrors.Register(ModuleName, 1120, "invalid contract") @@ -34,4 +26,5 @@ var ( ErrForeignCoinCapReached = sdkerrors.Register(ModuleName, 1123, "foreign coin cap reached") ErrCallNonContract = sdkerrors.Register(ModuleName, 1124, "can't call a non-contract address") ErrForeignCoinAlreadyExist = sdkerrors.Register(ModuleName, 1125, "foreign coin already exist") + ErrInvalidHash = sdkerrors.Register(ModuleName, 1126, "invalid hash") ) diff --git a/x/fungible/types/events.pb.go b/x/fungible/types/events.pb.go index 9f3f881138..3216373f9a 100644 --- a/x/fungible/types/events.pb.go +++ b/x/fungible/types/events.pb.go @@ -377,55 +377,235 @@ func (m *EventZRC20PausedStatusUpdated) GetSigner() string { return "" } +type EventSystemContractsDeployed struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + UniswapV2Factory string `protobuf:"bytes,2,opt,name=uniswap_v2_factory,json=uniswapV2Factory,proto3" json:"uniswap_v2_factory,omitempty"` + Wzeta string `protobuf:"bytes,3,opt,name=wzeta,proto3" json:"wzeta,omitempty"` + UniswapV2Router string `protobuf:"bytes,4,opt,name=uniswap_v2_router,json=uniswapV2Router,proto3" json:"uniswap_v2_router,omitempty"` + ConnectorZevm string `protobuf:"bytes,5,opt,name=connector_zevm,json=connectorZevm,proto3" json:"connector_zevm,omitempty"` + SystemContract string `protobuf:"bytes,6,opt,name=system_contract,json=systemContract,proto3" json:"system_contract,omitempty"` + Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *EventSystemContractsDeployed) Reset() { *m = EventSystemContractsDeployed{} } +func (m *EventSystemContractsDeployed) String() string { return proto.CompactTextString(m) } +func (*EventSystemContractsDeployed) ProtoMessage() {} +func (*EventSystemContractsDeployed) Descriptor() ([]byte, []int) { + return fileDescriptor_858e6494730deffd, []int{4} +} +func (m *EventSystemContractsDeployed) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSystemContractsDeployed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSystemContractsDeployed.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventSystemContractsDeployed) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSystemContractsDeployed.Merge(m, src) +} +func (m *EventSystemContractsDeployed) XXX_Size() int { + return m.Size() +} +func (m *EventSystemContractsDeployed) XXX_DiscardUnknown() { + xxx_messageInfo_EventSystemContractsDeployed.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSystemContractsDeployed proto.InternalMessageInfo + +func (m *EventSystemContractsDeployed) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *EventSystemContractsDeployed) GetUniswapV2Factory() string { + if m != nil { + return m.UniswapV2Factory + } + return "" +} + +func (m *EventSystemContractsDeployed) GetWzeta() string { + if m != nil { + return m.Wzeta + } + return "" +} + +func (m *EventSystemContractsDeployed) GetUniswapV2Router() string { + if m != nil { + return m.UniswapV2Router + } + return "" +} + +func (m *EventSystemContractsDeployed) GetConnectorZevm() string { + if m != nil { + return m.ConnectorZevm + } + return "" +} + +func (m *EventSystemContractsDeployed) GetSystemContract() string { + if m != nil { + return m.SystemContract + } + return "" +} + +func (m *EventSystemContractsDeployed) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type EventBytecodeUpdated struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + NewBytecodeHash string `protobuf:"bytes,3,opt,name=new_bytecode_hash,json=newBytecodeHash,proto3" json:"new_bytecode_hash,omitempty"` + OldBytecodeHash string `protobuf:"bytes,4,opt,name=old_bytecode_hash,json=oldBytecodeHash,proto3" json:"old_bytecode_hash,omitempty"` + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *EventBytecodeUpdated) Reset() { *m = EventBytecodeUpdated{} } +func (m *EventBytecodeUpdated) String() string { return proto.CompactTextString(m) } +func (*EventBytecodeUpdated) ProtoMessage() {} +func (*EventBytecodeUpdated) Descriptor() ([]byte, []int) { + return fileDescriptor_858e6494730deffd, []int{5} +} +func (m *EventBytecodeUpdated) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBytecodeUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBytecodeUpdated.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventBytecodeUpdated) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBytecodeUpdated.Merge(m, src) +} +func (m *EventBytecodeUpdated) XXX_Size() int { + return m.Size() +} +func (m *EventBytecodeUpdated) XXX_DiscardUnknown() { + xxx_messageInfo_EventBytecodeUpdated.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBytecodeUpdated proto.InternalMessageInfo + +func (m *EventBytecodeUpdated) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *EventBytecodeUpdated) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *EventBytecodeUpdated) GetNewBytecodeHash() string { + if m != nil { + return m.NewBytecodeHash + } + return "" +} + +func (m *EventBytecodeUpdated) GetOldBytecodeHash() string { + if m != nil { + return m.OldBytecodeHash + } + return "" +} + +func (m *EventBytecodeUpdated) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + func init() { proto.RegisterType((*EventSystemContractUpdated)(nil), "zetachain.zetacore.fungible.EventSystemContractUpdated") proto.RegisterType((*EventZRC20Deployed)(nil), "zetachain.zetacore.fungible.EventZRC20Deployed") proto.RegisterType((*EventZRC20WithdrawFeeUpdated)(nil), "zetachain.zetacore.fungible.EventZRC20WithdrawFeeUpdated") proto.RegisterType((*EventZRC20PausedStatusUpdated)(nil), "zetachain.zetacore.fungible.EventZRC20PausedStatusUpdated") + proto.RegisterType((*EventSystemContractsDeployed)(nil), "zetachain.zetacore.fungible.EventSystemContractsDeployed") + proto.RegisterType((*EventBytecodeUpdated)(nil), "zetachain.zetacore.fungible.EventBytecodeUpdated") } func init() { proto.RegisterFile("fungible/events.proto", fileDescriptor_858e6494730deffd) } var fileDescriptor_858e6494730deffd = []byte{ - // 593 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xae, 0x9b, 0x36, 0x6d, 0xa6, 0x97, 0xbf, 0xff, 0x50, 0x90, 0x49, 0xc1, 0xaa, 0xc2, 0x82, - 0x6e, 0x6a, 0x57, 0x45, 0x3c, 0x40, 0x29, 0x17, 0x55, 0x02, 0x09, 0xa5, 0x54, 0x48, 0xdd, 0x58, - 0x13, 0xcf, 0xa9, 0x3b, 0x92, 0x3d, 0x63, 0x79, 0x26, 0xb8, 0xee, 0x53, 0xb0, 0xe3, 0x5d, 0x78, - 0x02, 0x96, 0x65, 0xc7, 0x12, 0x35, 0x2f, 0x82, 0xe6, 0xe2, 0x5c, 0x40, 0x94, 0xac, 0x72, 0xce, - 0xe4, 0x3b, 0xe7, 0xfb, 0xfc, 0x9d, 0x33, 0x83, 0xee, 0x5f, 0x0c, 0x79, 0xca, 0x06, 0x19, 0x44, - 0xf0, 0x09, 0xb8, 0x92, 0x61, 0x51, 0x0a, 0x25, 0xf0, 0xce, 0x35, 0x28, 0x92, 0x5c, 0x12, 0xc6, - 0x43, 0x13, 0x89, 0x12, 0xc2, 0x06, 0xd9, 0xbd, 0x97, 0x88, 0x3c, 0x17, 0x3c, 0xb2, 0x3f, 0xb6, - 0xa2, 0xfb, 0xff, 0xb8, 0x91, 0xba, 0x72, 0x47, 0xdb, 0xa9, 0x48, 0x85, 0x09, 0x23, 0x1d, 0xd9, - 0xd3, 0xde, 0x57, 0x0f, 0x75, 0x5f, 0x69, 0xae, 0xd3, 0x5a, 0x2a, 0xc8, 0x8f, 0x05, 0x57, 0x25, - 0x49, 0xd4, 0x59, 0x41, 0x89, 0x02, 0x8a, 0x77, 0xd1, 0x7a, 0x2e, 0xd3, 0x58, 0xd5, 0x05, 0xc4, - 0xc3, 0x32, 0xf3, 0xbd, 0x5d, 0x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x33, - 0x0a, 0x16, 0x7e, 0x8c, 0x82, 0x85, 0xf3, 0x28, 0x65, 0xea, 0x72, 0x38, 0xd0, 0x83, 0x8e, 0x34, - 0xe1, 0xbe, 0xe1, 0x8e, 0x1a, 0xee, 0xe8, 0x2a, 0x9a, 0x3c, 0x3a, 0x75, 0x01, 0x72, 0xd0, 0x36, - 0x4f, 0xcc, 0xb3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x60, 0xaf, 0x2f, 0xd6, 0x04, 0x00, - 0x00, + // 756 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xdf, 0x6e, 0xd3, 0x3e, + 0x14, 0x5e, 0xd6, 0xad, 0x5b, 0xbd, 0x3f, 0xed, 0xfc, 0xeb, 0x0f, 0x85, 0x0e, 0xaa, 0xa9, 0x08, + 0x31, 0x26, 0xd6, 0x4c, 0x45, 0x3c, 0xc0, 0x36, 0x18, 0x4c, 0x02, 0x09, 0x75, 0x0c, 0xa4, 0xdd, + 0x44, 0x6e, 0x72, 0x96, 0x46, 0x4a, 0xec, 0x2a, 0x76, 0x9b, 0x65, 0x4f, 0xc1, 0x1d, 0x3c, 0x0b, + 0x4f, 0xc0, 0xe5, 0x10, 0x37, 0x5c, 0xa2, 0xf5, 0x45, 0x90, 0x1d, 0x27, 0x6d, 0x86, 0x36, 0xb6, + 0xab, 0xfa, 0xb8, 0xdf, 0x39, 0xe7, 0xf3, 0xe7, 0xcf, 0x27, 0xe8, 0xff, 0xd3, 0x21, 0xf5, 0xfc, + 0x5e, 0x00, 0x16, 0x8c, 0x80, 0x0a, 0xde, 0x1e, 0x44, 0x4c, 0x30, 0xbc, 0x7e, 0x0e, 0x82, 0x38, + 0x7d, 0xe2, 0xd3, 0xb6, 0x5a, 0xb1, 0x08, 0xda, 0x19, 0xb2, 0xf1, 0x9f, 0xc3, 0xc2, 0x90, 0x51, + 0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xab, 0xc4, 0x02, 0xb7, 0x80, 0x9d, 0x9c, 0x6a, 0x7e, 0xfa, 0x54, 0x7b, + 0x87, 0xdf, 0x2f, 0x9b, 0xc6, 0xc5, 0x65, 0xd3, 0xf8, 0x7d, 0xd9, 0x34, 0x3e, 0x8f, 0x9b, 0x33, + 0x17, 0xe3, 0xe6, 0xcc, 0xaf, 0x71, 0x73, 0xe6, 0xc4, 0xf2, 0x7c, 0xd1, 0x1f, 0xf6, 0xe4, 0xcb, + 0xb6, 0xe4, 0xa5, 0x6c, 0x2b, 0xb3, 0x59, 0x99, 0xd9, 0xac, 0x33, 0x6b, 0xf2, 0x95, 0x49, 0x06, + 0xc0, 0x7b, 0x65, 0xf5, 0x4d, 0x79, 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0x50, 0x31, 0x7b, 0x39, + 0xc7, 0x06, 0x00, 0x00, } func (m *EventSystemContractUpdated) Marshal() (dAtA []byte, err error) { @@ -690,6 +870,136 @@ func (m *EventZRC20PausedStatusUpdated) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *EventSystemContractsDeployed) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventSystemContractsDeployed) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSystemContractsDeployed) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x3a + } + if len(m.SystemContract) > 0 { + i -= len(m.SystemContract) + copy(dAtA[i:], m.SystemContract) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SystemContract))) + i-- + dAtA[i] = 0x32 + } + if len(m.ConnectorZevm) > 0 { + i -= len(m.ConnectorZevm) + copy(dAtA[i:], m.ConnectorZevm) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ConnectorZevm))) + i-- + dAtA[i] = 0x2a + } + if len(m.UniswapV2Router) > 0 { + i -= len(m.UniswapV2Router) + copy(dAtA[i:], m.UniswapV2Router) + i = encodeVarintEvents(dAtA, i, uint64(len(m.UniswapV2Router))) + i-- + dAtA[i] = 0x22 + } + if len(m.Wzeta) > 0 { + i -= len(m.Wzeta) + copy(dAtA[i:], m.Wzeta) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Wzeta))) + i-- + dAtA[i] = 0x1a + } + if len(m.UniswapV2Factory) > 0 { + i -= len(m.UniswapV2Factory) + copy(dAtA[i:], m.UniswapV2Factory) + i = encodeVarintEvents(dAtA, i, uint64(len(m.UniswapV2Factory))) + i-- + dAtA[i] = 0x12 + } + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MsgTypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBytecodeUpdated) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventBytecodeUpdated) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBytecodeUpdated) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if len(m.OldBytecodeHash) > 0 { + i -= len(m.OldBytecodeHash) + copy(dAtA[i:], m.OldBytecodeHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.OldBytecodeHash))) + i-- + dAtA[i] = 0x22 + } + if len(m.NewBytecodeHash) > 0 { + i -= len(m.NewBytecodeHash) + copy(dAtA[i:], m.NewBytecodeHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewBytecodeHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MsgTypeUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -836,6 +1146,72 @@ func (m *EventZRC20PausedStatusUpdated) Size() (n int) { return n } +func (m *EventSystemContractsDeployed) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.UniswapV2Factory) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Wzeta) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.UniswapV2Router) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.ConnectorZevm) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.SystemContract) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBytecodeUpdated) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewBytecodeHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.OldBytecodeHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1783,6 +2159,490 @@ func (m *EventZRC20PausedStatusUpdated) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventSystemContractsDeployed) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventSystemContractsDeployed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSystemContractsDeployed: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UniswapV2Factory", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UniswapV2Factory = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Wzeta", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Wzeta = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UniswapV2Router", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UniswapV2Router = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectorZevm", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectorZevm = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SystemContract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SystemContract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBytecodeUpdated) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventBytecodeUpdated: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBytecodeUpdated: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewBytecodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewBytecodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldBytecodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OldBytecodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/fungible/types/message_deploy_system_contracts.go b/x/fungible/types/message_deploy_system_contracts.go new file mode 100644 index 0000000000..579df47a25 --- /dev/null +++ b/x/fungible/types/message_deploy_system_contracts.go @@ -0,0 +1,45 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgDeploySystemContracts = "deploy_system_contract" + +var _ sdk.Msg = &MsgDeploySystemContracts{} + +func NewMsgDeploySystemContracts(creator string) *MsgDeploySystemContracts { + return &MsgDeploySystemContracts{ + Creator: creator, + } +} + +func (msg *MsgDeploySystemContracts) Route() string { + return RouterKey +} + +func (msg *MsgDeploySystemContracts) Type() string { + return TypeMsgDeployFungibleCoinZRC20 +} + +func (msg *MsgDeploySystemContracts) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDeploySystemContracts) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDeploySystemContracts) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/fungible/types/message_deploy_system_contracts_test.go b/x/fungible/types/message_deploy_system_contracts_test.go new file mode 100644 index 0000000000..b14aa419ed --- /dev/null +++ b/x/fungible/types/message_deploy_system_contracts_test.go @@ -0,0 +1,42 @@ +package types_test + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestMsgDeploySystemContract_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgDeploySystemContracts + err error + }{ + { + name: "invalid address", + msg: types.MsgDeploySystemContracts{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "valid message", + msg: types.MsgDeploySystemContracts{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/fungible/types/message_update_contract_bytecode.go b/x/fungible/types/message_update_contract_bytecode.go index a8a10cb5bd..212526b558 100644 --- a/x/fungible/types/message_update_contract_bytecode.go +++ b/x/fungible/types/message_update_contract_bytecode.go @@ -13,12 +13,14 @@ const TypeMsgUpdateContractBytecode = "update_contract_bytecode" var _ sdk.Msg = &MsgUpdateContractBytecode{} func NewMsgUpdateContractBytecode( - creator string, contractAddress ethcommon.Address, newBytecodeAddress ethcommon.Address, + creator string, + contractAddress string, + newCodeHash string, ) *MsgUpdateContractBytecode { return &MsgUpdateContractBytecode{ - Creator: creator, - ContractAddress: contractAddress.Hex(), - NewBytecodeAddress: newBytecodeAddress.Hex(), + Creator: creator, + ContractAddress: contractAddress, + NewCodeHash: newCodeHash, } } @@ -53,9 +55,10 @@ func (msg *MsgUpdateContractBytecode) ValidateBasic() error { return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", msg.ContractAddress) } - // check if the bytecode contract address is valid - if !ethcommon.IsHexAddress(msg.NewBytecodeAddress) { - return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", msg.ContractAddress) + // check if the new code hash is valid, it should be 32 bytes + // 32 bytes = 64 hex characters + 0x prefix + if len(msg.NewCodeHash) != 66 { + return cosmoserror.Wrapf(sdkerrors.ErrInvalidRequest, "invalid new code hash length (%d)", len(msg.NewCodeHash)) } return nil diff --git a/x/fungible/types/message_update_contract_bytecode_test.go b/x/fungible/types/message_update_contract_bytecode_test.go index 23a1ee2d97..02e8b3cfdd 100644 --- a/x/fungible/types/message_update_contract_bytecode_test.go +++ b/x/fungible/types/message_update_contract_bytecode_test.go @@ -17,36 +17,36 @@ func TestMsgUpdateContractBytecode_ValidateBasic(t *testing.T) { { name: "valid", msg: types.MsgUpdateContractBytecode{ - Creator: sample.AccAddress(), - ContractAddress: sample.EthAddress().Hex(), - NewBytecodeAddress: sample.EthAddress().Hex(), + Creator: sample.AccAddress(), + ContractAddress: sample.EthAddress().Hex(), + NewCodeHash: sample.Hash().Hex(), }, wantError: false, }, { name: "invalid creator", msg: types.MsgUpdateContractBytecode{ - Creator: "invalid", - ContractAddress: sample.EthAddress().Hex(), - NewBytecodeAddress: sample.EthAddress().Hex(), + Creator: "invalid", + ContractAddress: sample.EthAddress().Hex(), + NewCodeHash: sample.Hash().Hex(), }, wantError: true, }, { name: "invalid contract address", msg: types.MsgUpdateContractBytecode{ - Creator: sample.AccAddress(), - ContractAddress: "invalid", - NewBytecodeAddress: sample.EthAddress().Hex(), + Creator: sample.AccAddress(), + ContractAddress: "invalid", + NewCodeHash: sample.Hash().Hex(), }, wantError: true, }, { - name: "invalid bytecode address", + name: "invalid new code hash", msg: types.MsgUpdateContractBytecode{ - Creator: sample.AccAddress(), - ContractAddress: sample.EthAddress().Hex(), - NewBytecodeAddress: "invalid", + Creator: sample.AccAddress(), + ContractAddress: sample.EthAddress().Hex(), + NewCodeHash: "invalid", }, wantError: true, }, diff --git a/x/fungible/types/query.pb.go b/x/fungible/types/query.pb.go index c8db6b9a46..89ad3937b2 100644 --- a/x/fungible/types/query.pb.go +++ b/x/fungible/types/query.pb.go @@ -696,6 +696,94 @@ func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) GetBalance() string { return "" } +type QueryCodeHashRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryCodeHashRequest) Reset() { *m = QueryCodeHashRequest{} } +func (m *QueryCodeHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCodeHashRequest) ProtoMessage() {} +func (*QueryCodeHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d671b6e9298b37cd, []int{14} +} +func (m *QueryCodeHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeHashRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCodeHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeHashRequest.Merge(m, src) +} +func (m *QueryCodeHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeHashRequest proto.InternalMessageInfo + +func (m *QueryCodeHashRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type QueryCodeHashResponse struct { + CodeHash string `protobuf:"bytes,1,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"` +} + +func (m *QueryCodeHashResponse) Reset() { *m = QueryCodeHashResponse{} } +func (m *QueryCodeHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCodeHashResponse) ProtoMessage() {} +func (*QueryCodeHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d671b6e9298b37cd, []int{15} +} +func (m *QueryCodeHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCodeHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCodeHashResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryCodeHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCodeHashResponse.Merge(m, src) +} +func (m *QueryCodeHashResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCodeHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCodeHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCodeHashResponse proto.InternalMessageInfo + +func (m *QueryCodeHashResponse) GetCodeHash() string { + if m != nil { + return m.CodeHash + } + return "" +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "zetachain.zetacore.fungible.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "zetachain.zetacore.fungible.QueryParamsResponse") @@ -712,65 +800,72 @@ func init() { proto.RegisterType((*QueryAllGasStabilityPoolBalance)(nil), "zetachain.zetacore.fungible.QueryAllGasStabilityPoolBalance") proto.RegisterType((*QueryAllGasStabilityPoolBalanceResponse)(nil), "zetachain.zetacore.fungible.QueryAllGasStabilityPoolBalanceResponse") proto.RegisterType((*QueryAllGasStabilityPoolBalanceResponse_Balance)(nil), "zetachain.zetacore.fungible.QueryAllGasStabilityPoolBalanceResponse.Balance") + proto.RegisterType((*QueryCodeHashRequest)(nil), "zetachain.zetacore.fungible.QueryCodeHashRequest") + proto.RegisterType((*QueryCodeHashResponse)(nil), "zetachain.zetacore.fungible.QueryCodeHashResponse") } func init() { proto.RegisterFile("fungible/query.proto", fileDescriptor_d671b6e9298b37cd) } var fileDescriptor_d671b6e9298b37cd = []byte{ - // 846 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0x4d, 0x4f, 0xdb, 0x48, - 0x18, 0xc7, 0x63, 0x58, 0x5e, 0x76, 0x60, 0x59, 0x69, 0x36, 0xab, 0x65, 0x0d, 0x38, 0xbb, 0x03, - 0x0b, 0x5b, 0x4a, 0xed, 0x02, 0x87, 0x52, 0x1a, 0x55, 0x4d, 0xa8, 0x40, 0x48, 0x3d, 0xd0, 0x70, - 0x69, 0x7b, 0x89, 0x26, 0xc9, 0x60, 0x2c, 0x39, 0x9e, 0x90, 0x71, 0x10, 0x29, 0xe2, 0xd2, 0x4f, - 0x80, 0xd4, 0x6f, 0xd2, 0x4b, 0x2f, 0xfd, 0x00, 0x1c, 0x91, 0x2a, 0x55, 0xed, 0xa5, 0x6a, 0x43, - 0xfb, 0x3d, 0xaa, 0x8c, 0x1f, 0x9b, 0x38, 0xb5, 0x13, 0x2b, 0xdc, 0xec, 0x99, 0xe7, 0xe5, 0xf7, - 0x9f, 0x79, 0xfc, 0x4f, 0x50, 0xfa, 0xa0, 0xe1, 0x98, 0x56, 0xc9, 0x66, 0xc6, 0x51, 0x83, 0xd5, - 0x9b, 0x7a, 0xad, 0xce, 0x5d, 0x8e, 0x67, 0x5e, 0x32, 0x97, 0x96, 0x0f, 0xa9, 0xe5, 0xe8, 0xf2, - 0x89, 0xd7, 0x99, 0xee, 0x07, 0xaa, 0xcb, 0x65, 0x2e, 0xaa, 0x5c, 0x18, 0x25, 0x2a, 0x20,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, 0xbf, 0x62, 0x3c, 0x0b, 0x67, 0x13, 0x61, 0xc4, 0x64, 0xab, 0x8f, 0x6f, 0x92, - 0x1d, 0xa8, 0xb9, 0x27, 0xd5, 0xac, 0x62, 0x23, 0x52, 0x8d, 0x49, 0x45, 0x51, 0xf8, 0xe9, 0xc5, - 0x1a, 0xe7, 0xb6, 0x6f, 0x99, 0xf8, 0x6b, 0x84, 0x30, 0xff, 0x7b, 0x1f, 0x4c, 0x18, 0x64, 0x0f, - 0x28, 0xac, 0xcb, 0x96, 0x48, 0x5e, 0x0a, 0xcb, 0xe2, 0xcd, 0xa4, 0xc2, 0xc0, 0x77, 0x8c, 0x53, - 0xdf, 0xaa, 0xce, 0x70, 0x4b, 0x41, 0x6a, 0x4c, 0x9f, 0xf6, 0x67, 0x93, 0xbd, 0x89, 0x7f, 0x26, - 0x91, 0xd9, 0xdf, 0x7d, 0xc9, 0x23, 0x29, 0x73, 0x13, 0x6f, 0x74, 0xca, 0xf4, 0xcb, 0x25, 0xd1, - 0x9b, 0xdf, 0xbd, 0x68, 0x69, 0xca, 0x65, 0x4b, 0x53, 0xbe, 0xb4, 0x34, 0xe5, 0xfc, 0x4a, 0x4b, - 0x5d, 0x5e, 0x69, 0xa9, 0x8f, 0x57, 0x5a, 0xea, 0x85, 0x61, 0x5a, 0xee, 0x61, 0xa3, 0xa4, 0x97, - 0x79, 0x35, 0xb2, 0xfa, 0xc9, 0x75, 0x7d, 0xb7, 0x59, 0x63, 0xa2, 0x34, 0x2a, 0xff, 0xaf, 0xae, - 0xff, 0x08, 0x00, 0x00, 0xff, 0xff, 0x88, 0x06, 0xca, 0xa7, 0x99, 0x0b, 0x00, 0x00, + // 927 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xa6, 0x34, 0x49, 0x5f, 0x43, 0x91, 0x06, 0x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0x89, 0x9a, + 0x0f, 0x95, 0x9a, 0x6d, 0xe2, 0x64, 0xaa, 0xf1, 0x98, 0x6c, 0x48, 0x0d, 0x6f, 0x74, 0x85, 0x08, + 0xb4, 0x35, 0x93, 0xbf, 0x33, 0x84, 0x69, 0x5f, 0x99, 0x4f, 0x18, 0xa2, 0xe7, 0x14, 0x36, 0x65, + 0x7f, 0x74, 0x5f, 0x09, 0xdb, 0x23, 0xbb, 0x65, 0x85, 0xa1, 0xbf, 0x39, 0x43, 0x6d, 0x89, 0x67, + 0x64, 0x64, 0x80, 0x99, 0x53, 0x67, 0xfc, 0xb3, 0xd9, 0xbb, 0x8c, 0x4f, 0x97, 0x91, 0x59, 0xec, + 0xf2, 0xf4, 0x53, 0x25, 0x73, 0x97, 0x3c, 0x9e, 0x94, 0xa9, 0xd3, 0x95, 0xd1, 0x4b, 0x7e, 0x34, + 0x60, 0x45, 0x3b, 0x33, 0xd9, 0x2e, 0x26, 0x35, 0xe5, 0xfb, 0xe6, 0xce, 0xff, 0x81, 0x20, 0xeb, + 0x2d, 0xc5, 0x7a, 0x93, 0x3c, 0xc8, 0xbc, 0x9c, 0xe4, 0x4d, 0x70, 0x86, 0x38, 0x6d, 0x67, 0xfb, + 0x4f, 0x5f, 0x8c, 0x2c, 0xe3, 0xe5, 0xc8, 0x32, 0xfe, 0x1a, 0x59, 0xc6, 0xf3, 0x73, 0x6b, 0xe1, + 0xe5, 0xb9, 0xb5, 0xf0, 0xfb, 0xb9, 0xb5, 0xf0, 0x8d, 0xe3, 0xf9, 0x51, 0xbb, 0xdf, 0xb4, 0x5d, + 0xd1, 0xc9, 0xec, 0xc1, 0xb3, 0x8b, 0xc4, 0xd1, 0xa0, 0xcb, 0x65, 0x73, 0x49, 0xfd, 0x7b, 0x7f, + 0xf4, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0x51, 0x58, 0xac, 0xa7, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -799,6 +894,8 @@ type QueryClient interface { GasStabilityPoolBalance(ctx context.Context, in *QueryGetGasStabilityPoolBalance, opts ...grpc.CallOption) (*QueryGetGasStabilityPoolBalanceResponse, error) // Queries all gas stability pool balances. GasStabilityPoolBalanceAll(ctx context.Context, in *QueryAllGasStabilityPoolBalance, opts ...grpc.CallOption) (*QueryAllGasStabilityPoolBalanceResponse, error) + // Code hash query the code hash of a contract. + CodeHash(ctx context.Context, in *QueryCodeHashRequest, opts ...grpc.CallOption) (*QueryCodeHashResponse, error) } type queryClient struct { @@ -872,6 +969,15 @@ func (c *queryClient) GasStabilityPoolBalanceAll(ctx context.Context, in *QueryA return out, nil } +func (c *queryClient) CodeHash(ctx context.Context, in *QueryCodeHashRequest, opts ...grpc.CallOption) (*QueryCodeHashResponse, error) { + out := new(QueryCodeHashResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Query/CodeHash", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -888,6 +994,8 @@ type QueryServer interface { GasStabilityPoolBalance(context.Context, *QueryGetGasStabilityPoolBalance) (*QueryGetGasStabilityPoolBalanceResponse, error) // Queries all gas stability pool balances. GasStabilityPoolBalanceAll(context.Context, *QueryAllGasStabilityPoolBalance) (*QueryAllGasStabilityPoolBalanceResponse, error) + // Code hash query the code hash of a contract. + CodeHash(context.Context, *QueryCodeHashRequest) (*QueryCodeHashResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -915,6 +1023,9 @@ func (*UnimplementedQueryServer) GasStabilityPoolBalance(ctx context.Context, re func (*UnimplementedQueryServer) GasStabilityPoolBalanceAll(ctx context.Context, req *QueryAllGasStabilityPoolBalance) (*QueryAllGasStabilityPoolBalanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GasStabilityPoolBalanceAll not implemented") } +func (*UnimplementedQueryServer) CodeHash(ctx context.Context, req *QueryCodeHashRequest) (*QueryCodeHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CodeHash not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1046,6 +1157,24 @@ func _Query_GasStabilityPoolBalanceAll_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _Query_CodeHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCodeHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CodeHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.fungible.Query/CodeHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CodeHash(ctx, req.(*QueryCodeHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.fungible.Query", HandlerType: (*QueryServer)(nil), @@ -1078,6 +1207,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GasStabilityPoolBalanceAll", Handler: _Query_GasStabilityPoolBalanceAll_Handler, }, + { + MethodName: "CodeHash", + Handler: _Query_CodeHash_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "fungible/query.proto", @@ -1555,6 +1688,66 @@ func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) MarshalToSizedBuffer(d return len(dAtA) - i, nil } +func (m *QueryCodeHashRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCodeHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCodeHashResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryCodeHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCodeHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeHash) > 0 { + i -= len(m.CodeHash) + copy(dAtA[i:], m.CodeHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CodeHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1753,6 +1946,32 @@ func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) Size() (n int) { return n } +func (m *QueryCodeHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCodeHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CodeHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2946,6 +3165,170 @@ func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) Unmarshal(dAtA []byte) } return nil } +func (m *QueryCodeHashRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCodeHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCodeHashResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryCodeHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCodeHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/fungible/types/query.pb.gw.go b/x/fungible/types/query.pb.gw.go index 5338914d3f..c971723b1b 100644 --- a/x/fungible/types/query.pb.gw.go +++ b/x/fungible/types/query.pb.gw.go @@ -249,6 +249,60 @@ func local_request_Query_GasStabilityPoolBalanceAll_0(ctx context.Context, marsh } +func request_Query_CodeHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.CodeHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CodeHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCodeHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.CodeHash(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -416,6 +470,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CodeHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CodeHash_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CodeHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -597,6 +674,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CodeHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CodeHash_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CodeHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -614,6 +711,8 @@ var ( pattern_Query_GasStabilityPoolBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "fungible", "gas_stability_pool_balance", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_GasStabilityPoolBalanceAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"zeta-chain", "zetacore", "fungible", "gas_stability_pool_balance"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_CodeHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "fungible", "code_hash", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -630,4 +729,6 @@ var ( forward_Query_GasStabilityPoolBalance_0 = runtime.ForwardResponseMessage forward_Query_GasStabilityPoolBalanceAll_0 = runtime.ForwardResponseMessage + + forward_Query_CodeHash_0 = runtime.ForwardResponseMessage ) diff --git a/x/fungible/types/tx.pb.go b/x/fungible/types/tx.pb.go index 476981cc21..35820af781 100644 --- a/x/fungible/types/tx.pb.go +++ b/x/fungible/types/tx.pb.go @@ -56,6 +56,126 @@ func (UpdatePausedStatusAction) EnumDescriptor() ([]byte, []int) { return fileDescriptor_197fdedece277fa0, []int{0} } +type MsgDeploySystemContracts struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *MsgDeploySystemContracts) Reset() { *m = MsgDeploySystemContracts{} } +func (m *MsgDeploySystemContracts) String() string { return proto.CompactTextString(m) } +func (*MsgDeploySystemContracts) ProtoMessage() {} +func (*MsgDeploySystemContracts) Descriptor() ([]byte, []int) { + return fileDescriptor_197fdedece277fa0, []int{0} +} +func (m *MsgDeploySystemContracts) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeploySystemContracts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeploySystemContracts.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeploySystemContracts) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeploySystemContracts.Merge(m, src) +} +func (m *MsgDeploySystemContracts) XXX_Size() int { + return m.Size() +} +func (m *MsgDeploySystemContracts) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeploySystemContracts.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeploySystemContracts proto.InternalMessageInfo + +func (m *MsgDeploySystemContracts) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type MsgDeploySystemContractsResponse struct { + UniswapV2Factory string `protobuf:"bytes,1,opt,name=uniswapV2Factory,proto3" json:"uniswapV2Factory,omitempty"` + Wzeta string `protobuf:"bytes,2,opt,name=wzeta,proto3" json:"wzeta,omitempty"` + UniswapV2Router string `protobuf:"bytes,3,opt,name=uniswapV2Router,proto3" json:"uniswapV2Router,omitempty"` + ConnectorZEVM string `protobuf:"bytes,4,opt,name=connectorZEVM,proto3" json:"connectorZEVM,omitempty"` + SystemContract string `protobuf:"bytes,5,opt,name=systemContract,proto3" json:"systemContract,omitempty"` +} + +func (m *MsgDeploySystemContractsResponse) Reset() { *m = MsgDeploySystemContractsResponse{} } +func (m *MsgDeploySystemContractsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeploySystemContractsResponse) ProtoMessage() {} +func (*MsgDeploySystemContractsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_197fdedece277fa0, []int{1} +} +func (m *MsgDeploySystemContractsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeploySystemContractsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeploySystemContractsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeploySystemContractsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeploySystemContractsResponse.Merge(m, src) +} +func (m *MsgDeploySystemContractsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeploySystemContractsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeploySystemContractsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeploySystemContractsResponse proto.InternalMessageInfo + +func (m *MsgDeploySystemContractsResponse) GetUniswapV2Factory() string { + if m != nil { + return m.UniswapV2Factory + } + return "" +} + +func (m *MsgDeploySystemContractsResponse) GetWzeta() string { + if m != nil { + return m.Wzeta + } + return "" +} + +func (m *MsgDeploySystemContractsResponse) GetUniswapV2Router() string { + if m != nil { + return m.UniswapV2Router + } + return "" +} + +func (m *MsgDeploySystemContractsResponse) GetConnectorZEVM() string { + if m != nil { + return m.ConnectorZEVM + } + return "" +} + +func (m *MsgDeploySystemContractsResponse) GetSystemContract() string { + if m != nil { + return m.SystemContract + } + return "" +} + type MsgUpdateZRC20WithdrawFee struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Zrc20Address string `protobuf:"bytes,2,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` @@ -67,7 +187,7 @@ func (m *MsgUpdateZRC20WithdrawFee) Reset() { *m = MsgUpdateZRC20Withdra func (m *MsgUpdateZRC20WithdrawFee) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20WithdrawFee) ProtoMessage() {} func (*MsgUpdateZRC20WithdrawFee) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{0} + return fileDescriptor_197fdedece277fa0, []int{2} } func (m *MsgUpdateZRC20WithdrawFee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,7 +237,7 @@ func (m *MsgUpdateZRC20WithdrawFeeResponse) Reset() { *m = MsgUpdateZRC2 func (m *MsgUpdateZRC20WithdrawFeeResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20WithdrawFeeResponse) ProtoMessage() {} func (*MsgUpdateZRC20WithdrawFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{1} + return fileDescriptor_197fdedece277fa0, []int{3} } func (m *MsgUpdateZRC20WithdrawFeeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -155,7 +275,7 @@ func (m *MsgUpdateSystemContract) Reset() { *m = MsgUpdateSystemContract func (m *MsgUpdateSystemContract) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSystemContract) ProtoMessage() {} func (*MsgUpdateSystemContract) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{2} + return fileDescriptor_197fdedece277fa0, []int{4} } func (m *MsgUpdateSystemContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -205,7 +325,7 @@ func (m *MsgUpdateSystemContractResponse) Reset() { *m = MsgUpdateSystem func (m *MsgUpdateSystemContractResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSystemContractResponse) ProtoMessage() {} func (*MsgUpdateSystemContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{3} + return fileDescriptor_197fdedece277fa0, []int{5} } func (m *MsgUpdateSystemContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -249,7 +369,7 @@ func (m *MsgDeployFungibleCoinZRC20) Reset() { *m = MsgDeployFungibleCoi func (m *MsgDeployFungibleCoinZRC20) String() string { return proto.CompactTextString(m) } func (*MsgDeployFungibleCoinZRC20) ProtoMessage() {} func (*MsgDeployFungibleCoinZRC20) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{4} + return fileDescriptor_197fdedece277fa0, []int{6} } func (m *MsgDeployFungibleCoinZRC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -342,7 +462,7 @@ func (m *MsgDeployFungibleCoinZRC20Response) Reset() { *m = MsgDeployFun func (m *MsgDeployFungibleCoinZRC20Response) String() string { return proto.CompactTextString(m) } func (*MsgDeployFungibleCoinZRC20Response) ProtoMessage() {} func (*MsgDeployFungibleCoinZRC20Response) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{5} + return fileDescriptor_197fdedece277fa0, []int{7} } func (m *MsgDeployFungibleCoinZRC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -387,7 +507,7 @@ func (m *MsgRemoveForeignCoin) Reset() { *m = MsgRemoveForeignCoin{} } func (m *MsgRemoveForeignCoin) String() string { return proto.CompactTextString(m) } func (*MsgRemoveForeignCoin) ProtoMessage() {} func (*MsgRemoveForeignCoin) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{6} + return fileDescriptor_197fdedece277fa0, []int{8} } func (m *MsgRemoveForeignCoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -437,7 +557,7 @@ func (m *MsgRemoveForeignCoinResponse) Reset() { *m = MsgRemoveForeignCo func (m *MsgRemoveForeignCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveForeignCoinResponse) ProtoMessage() {} func (*MsgRemoveForeignCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{7} + return fileDescriptor_197fdedece277fa0, []int{9} } func (m *MsgRemoveForeignCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -467,16 +587,16 @@ func (m *MsgRemoveForeignCoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveForeignCoinResponse proto.InternalMessageInfo type MsgUpdateContractBytecode struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - NewBytecodeAddress string `protobuf:"bytes,3,opt,name=new_bytecode_address,json=newBytecodeAddress,proto3" json:"new_bytecode_address,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + NewCodeHash string `protobuf:"bytes,3,opt,name=new_code_hash,json=newCodeHash,proto3" json:"new_code_hash,omitempty"` } func (m *MsgUpdateContractBytecode) Reset() { *m = MsgUpdateContractBytecode{} } func (m *MsgUpdateContractBytecode) String() string { return proto.CompactTextString(m) } func (*MsgUpdateContractBytecode) ProtoMessage() {} func (*MsgUpdateContractBytecode) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{8} + return fileDescriptor_197fdedece277fa0, []int{10} } func (m *MsgUpdateContractBytecode) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,22 +639,21 @@ func (m *MsgUpdateContractBytecode) GetContractAddress() string { return "" } -func (m *MsgUpdateContractBytecode) GetNewBytecodeAddress() string { +func (m *MsgUpdateContractBytecode) GetNewCodeHash() string { if m != nil { - return m.NewBytecodeAddress + return m.NewCodeHash } return "" } type MsgUpdateContractBytecodeResponse struct { - NewBytecodeHash []byte `protobuf:"bytes,1,opt,name=new_bytecode_hash,json=newBytecodeHash,proto3" json:"new_bytecode_hash,omitempty"` } func (m *MsgUpdateContractBytecodeResponse) Reset() { *m = MsgUpdateContractBytecodeResponse{} } func (m *MsgUpdateContractBytecodeResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateContractBytecodeResponse) ProtoMessage() {} func (*MsgUpdateContractBytecodeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{9} + return fileDescriptor_197fdedece277fa0, []int{11} } func (m *MsgUpdateContractBytecodeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -563,13 +682,6 @@ func (m *MsgUpdateContractBytecodeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateContractBytecodeResponse proto.InternalMessageInfo -func (m *MsgUpdateContractBytecodeResponse) GetNewBytecodeHash() []byte { - if m != nil { - return m.NewBytecodeHash - } - return nil -} - type MsgUpdateZRC20PausedStatus struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` @@ -580,7 +692,7 @@ func (m *MsgUpdateZRC20PausedStatus) Reset() { *m = MsgUpdateZRC20Paused func (m *MsgUpdateZRC20PausedStatus) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20PausedStatus) ProtoMessage() {} func (*MsgUpdateZRC20PausedStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{10} + return fileDescriptor_197fdedece277fa0, []int{12} } func (m *MsgUpdateZRC20PausedStatus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -637,7 +749,7 @@ func (m *MsgUpdateZRC20PausedStatusResponse) Reset() { *m = MsgUpdateZRC func (m *MsgUpdateZRC20PausedStatusResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20PausedStatusResponse) ProtoMessage() {} func (*MsgUpdateZRC20PausedStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{11} + return fileDescriptor_197fdedece277fa0, []int{13} } func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -676,7 +788,7 @@ func (m *MsgUpdateZRC20LiquidityCap) Reset() { *m = MsgUpdateZRC20Liquid func (m *MsgUpdateZRC20LiquidityCap) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20LiquidityCap) ProtoMessage() {} func (*MsgUpdateZRC20LiquidityCap) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{12} + return fileDescriptor_197fdedece277fa0, []int{14} } func (m *MsgUpdateZRC20LiquidityCap) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -726,7 +838,7 @@ func (m *MsgUpdateZRC20LiquidityCapResponse) Reset() { *m = MsgUpdateZRC func (m *MsgUpdateZRC20LiquidityCapResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateZRC20LiquidityCapResponse) ProtoMessage() {} func (*MsgUpdateZRC20LiquidityCapResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{13} + return fileDescriptor_197fdedece277fa0, []int{15} } func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -757,6 +869,8 @@ var xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse proto.InternalMessageInfo func init() { proto.RegisterEnum("zetachain.zetacore.fungible.UpdatePausedStatusAction", UpdatePausedStatusAction_name, UpdatePausedStatusAction_value) + proto.RegisterType((*MsgDeploySystemContracts)(nil), "zetachain.zetacore.fungible.MsgDeploySystemContracts") + proto.RegisterType((*MsgDeploySystemContractsResponse)(nil), "zetachain.zetacore.fungible.MsgDeploySystemContractsResponse") proto.RegisterType((*MsgUpdateZRC20WithdrawFee)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20WithdrawFee") proto.RegisterType((*MsgUpdateZRC20WithdrawFeeResponse)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20WithdrawFeeResponse") proto.RegisterType((*MsgUpdateSystemContract)(nil), "zetachain.zetacore.fungible.MsgUpdateSystemContract") @@ -776,65 +890,70 @@ func init() { func init() { proto.RegisterFile("fungible/tx.proto", fileDescriptor_197fdedece277fa0) } var fileDescriptor_197fdedece277fa0 = []byte{ - // 913 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x15, 0xad, 0xf8, 0xa1, 0x1b, 0x5b, 0x96, 0x59, 0x21, 0x61, 0xe5, 0x42, 0x76, 0x98, 0x02, - 0x51, 0x03, 0x58, 0x74, 0xd5, 0x47, 0x50, 0xa0, 0x4d, 0x61, 0x2b, 0x71, 0x1b, 0x20, 0x6a, 0x03, - 0x3a, 0x46, 0xd1, 0x6c, 0x88, 0x11, 0x39, 0xa6, 0x06, 0x15, 0x67, 0x54, 0xce, 0xa8, 0x8a, 0xb2, - 0xeb, 0xd6, 0xab, 0xa0, 0xfd, 0x8f, 0x02, 0xfd, 0x8b, 0x2c, 0xb3, 0x2c, 0xba, 0x08, 0x0a, 0xfb, - 0x3f, 0x8a, 0x82, 0xc3, 0x87, 0xa9, 0x07, 0x65, 0x4b, 0x5d, 0x69, 0x66, 0x74, 0xef, 0xe1, 0xb9, - 0xf7, 0x9e, 0x39, 0x24, 0x6c, 0x9d, 0xf6, 0xa9, 0x4b, 0xda, 0x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67, 0x9c, 0xd5, 0x88, 0xeb, 0xcc, 0xc3, 0x2a, 0x9d, 0x38, 0x17, 0xab, 0x69, 0xa6, - 0x71, 0xf8, 0xe4, 0xcd, 0x79, 0x55, 0x79, 0x7b, 0x5e, 0x55, 0xfe, 0x39, 0xaf, 0x2a, 0xaf, 0x2f, - 0xaa, 0xb9, 0xb7, 0x17, 0xd5, 0xdc, 0x5f, 0x17, 0xd5, 0xdc, 0x0b, 0x23, 0xe5, 0x55, 0x01, 0xf4, - 0x9e, 0x7c, 0x8a, 0x11, 0x3f, 0xc5, 0x78, 0x69, 0x5c, 0x7e, 0xdd, 0x06, 0xc6, 0xd5, 0x5e, 0x91, - 0x5f, 0xa6, 0x9f, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x42, 0x83, 0xe6, 0x96, 0xf6, 0x0a, 0x00, - 0x00, + // 998 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xae, 0xdb, 0xf5, 0x23, 0xef, 0x96, 0x34, 0x3b, 0x84, 0xcd, 0xa4, 0x28, 0xdd, 0xbc, 0x89, + 0x95, 0x49, 0x8d, 0x47, 0x18, 0x4c, 0x48, 0x6c, 0xa8, 0xcd, 0x5a, 0x98, 0xb4, 0xa0, 0xc9, 0x5d, + 0x87, 0xe8, 0x8d, 0x75, 0x6a, 0x9f, 0x3a, 0x16, 0xf1, 0x39, 0xc6, 0xe7, 0x84, 0x2c, 0xbb, 0x43, + 0xe2, 0xaa, 0x12, 0x68, 0x12, 0xff, 0x03, 0x89, 0x7f, 0xb1, 0xcb, 0x5d, 0x22, 0x84, 0x26, 0xd4, + 0xfe, 0x11, 0xe4, 0xe3, 0x8f, 0x3a, 0x1f, 0x4e, 0x9b, 0x70, 0x95, 0x73, 0xde, 0xbc, 0xef, 0xe3, + 0xe7, 0xfd, 0x7a, 0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 0x84, 0x2e, 0xc9, 0x3c, 0xca, 0x0b, 0xda, 0x80, 0xf2, 0x11, 0x0b, 0x88, 0xeb, 0x50, 0x53, 0xae, + 0x9e, 0xe9, 0xda, 0x72, 0x20, 0x17, 0x8c, 0x52, 0x6c, 0x6f, 0x86, 0xe6, 0x27, 0x36, 0xaa, 0xc2, + 0x8a, 0x4d, 0x2c, 0xd7, 0xc3, 0x1d, 0x2e, 0x47, 0xb1, 0x68, 0xa4, 0x77, 0x84, 0xe0, 0x12, 0xc5, + 0x1e, 0x89, 0x67, 0x4f, 0x9e, 0xd1, 0x35, 0x58, 0xe2, 0x7d, 0xef, 0x90, 0x75, 0xa2, 0x51, 0x30, + 0xe2, 0x1b, 0xda, 0x84, 0x82, 0xc5, 0x5c, 0x6a, 0x86, 0xcd, 0x91, 0xdd, 0x2c, 0x35, 0xca, 0xf5, + 0x78, 0xad, 0xc3, 0x3c, 0x9e, 0xf7, 0x7d, 0x62, 0xac, 0x58, 0xf1, 0x09, 0xad, 0x41, 0xe1, 0xac, + 0xf9, 0x2b, 0x92, 0xd9, 0x8a, 0x93, 0x34, 0xf2, 0x11, 0x68, 0xf9, 0xb5, 0x48, 0xb7, 0x56, 0x85, + 0xe5, 0xa4, 0x01, 0x71, 0x4d, 0xe2, 0xab, 0xf6, 0x18, 0x2a, 0x2d, 0xee, 0x18, 0xc4, 0x63, 0x3f, + 0x91, 0xdd, 0x38, 0x5d, 0xe6, 0xd2, 0x09, 0x55, 0x4c, 0x32, 0x9d, 0x3f, 0xcb, 0x54, 0xab, 0xc1, + 0x87, 0xe3, 0x50, 0xd2, 0x96, 0xfd, 0xa2, 0x64, 0x76, 0x2f, 0x69, 0xe8, 0x76, 0x5f, 0x10, 0x8b, + 0xd9, 0x93, 0x76, 0xef, 0x63, 0x28, 0xe7, 0x4c, 0xd0, 0xaa, 0x35, 0x38, 0x38, 0x48, 0x8b, 0xd6, + 0x24, 0x04, 0x34, 0xdb, 0x98, 0xb7, 0x63, 0x51, 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0x5f, + 0xcd, 0x18, 0x98, 0xb2, 0xfa, 0x59, 0x81, 0xab, 0xa3, 0x12, 0xf1, 0xc9, 0x79, 0xb0, 0x23, 0x21, + 0xd5, 0x2f, 0xa6, 0x0e, 0x49, 0x39, 0x1c, 0x2b, 0x50, 0x19, 0xfb, 0x2a, 0xba, 0x7f, 0x1e, 0xe6, + 0xb8, 0xa8, 0xea, 0x97, 0xb3, 0x44, 0xa5, 0x64, 0x5e, 0x2b, 0x70, 0x2d, 0x47, 0xcc, 0x3e, 0xbf, + 0x18, 0xf0, 0x70, 0x5c, 0xf5, 0xd1, 0x6c, 0x71, 0x63, 0x28, 0x8d, 0xfc, 0xb6, 0xb9, 0x20, 0xa5, + 0xe1, 0xb8, 0x8b, 0x52, 0xca, 0xfb, 0xfd, 0x20, 0x87, 0x39, 0x4f, 0x46, 0x1f, 0x4c, 0x81, 0x9d, + 0x0d, 0x3c, 0x7f, 0x98, 0xcf, 0x11, 0xc2, 0x61, 0x56, 0x03, 0x2a, 0x38, 0x0d, 0xab, 0x6c, 0xe0, + 0x54, 0xac, 0xc6, 0x89, 0xd8, 0xf6, 0x93, 0x37, 0x27, 0x35, 0xe5, 0xed, 0x49, 0x4d, 0xf9, 0xf7, + 0xa4, 0xa6, 0xbc, 0x3e, 0xad, 0xcd, 0xbd, 0x3d, 0xad, 0xcd, 0xfd, 0x75, 0x5a, 0x9b, 0x3b, 0xd0, + 0x33, 0xda, 0x19, 0x42, 0x6f, 0xca, 0xa7, 0xe8, 0xc9, 0x53, 0xf4, 0x97, 0xfa, 0xd9, 0x1f, 0x89, + 0x50, 0x48, 0x0f, 0x97, 0xe4, 0x9f, 0x80, 0x4f, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x18, + 0xdc, 0x6a, 0x61, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -849,6 +968,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + DeploySystemContracts(ctx context.Context, in *MsgDeploySystemContracts, opts ...grpc.CallOption) (*MsgDeploySystemContractsResponse, error) DeployFungibleCoinZRC20(ctx context.Context, in *MsgDeployFungibleCoinZRC20, opts ...grpc.CallOption) (*MsgDeployFungibleCoinZRC20Response, error) RemoveForeignCoin(ctx context.Context, in *MsgRemoveForeignCoin, opts ...grpc.CallOption) (*MsgRemoveForeignCoinResponse, error) UpdateSystemContract(ctx context.Context, in *MsgUpdateSystemContract, opts ...grpc.CallOption) (*MsgUpdateSystemContractResponse, error) @@ -866,6 +986,15 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) DeploySystemContracts(ctx context.Context, in *MsgDeploySystemContracts, opts ...grpc.CallOption) (*MsgDeploySystemContractsResponse, error) { + out := new(MsgDeploySystemContractsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/DeploySystemContracts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) DeployFungibleCoinZRC20(ctx context.Context, in *MsgDeployFungibleCoinZRC20, opts ...grpc.CallOption) (*MsgDeployFungibleCoinZRC20Response, error) { out := new(MsgDeployFungibleCoinZRC20Response) err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/DeployFungibleCoinZRC20", in, out, opts...) @@ -931,6 +1060,7 @@ func (c *msgClient) UpdateZRC20LiquidityCap(ctx context.Context, in *MsgUpdateZR // MsgServer is the server API for Msg service. type MsgServer interface { + DeploySystemContracts(context.Context, *MsgDeploySystemContracts) (*MsgDeploySystemContractsResponse, error) DeployFungibleCoinZRC20(context.Context, *MsgDeployFungibleCoinZRC20) (*MsgDeployFungibleCoinZRC20Response, error) RemoveForeignCoin(context.Context, *MsgRemoveForeignCoin) (*MsgRemoveForeignCoinResponse, error) UpdateSystemContract(context.Context, *MsgUpdateSystemContract) (*MsgUpdateSystemContractResponse, error) @@ -944,6 +1074,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) DeploySystemContracts(ctx context.Context, req *MsgDeploySystemContracts) (*MsgDeploySystemContractsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeploySystemContracts not implemented") +} func (*UnimplementedMsgServer) DeployFungibleCoinZRC20(ctx context.Context, req *MsgDeployFungibleCoinZRC20) (*MsgDeployFungibleCoinZRC20Response, error) { return nil, status.Errorf(codes.Unimplemented, "method DeployFungibleCoinZRC20 not implemented") } @@ -970,6 +1103,24 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_DeploySystemContracts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeploySystemContracts) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeploySystemContracts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.fungible.Msg/DeploySystemContracts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeploySystemContracts(ctx, req.(*MsgDeploySystemContracts)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_DeployFungibleCoinZRC20_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgDeployFungibleCoinZRC20) if err := dec(in); err != nil { @@ -1100,6 +1251,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.fungible.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "DeploySystemContracts", + Handler: _Msg_DeploySystemContracts_Handler, + }, { MethodName: "DeployFungibleCoinZRC20", Handler: _Msg_DeployFungibleCoinZRC20_Handler, @@ -1133,6 +1288,94 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "fungible/tx.proto", } +func (m *MsgDeploySystemContracts) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeploySystemContracts) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeploySystemContracts) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeploySystemContractsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeploySystemContractsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeploySystemContractsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SystemContract) > 0 { + i -= len(m.SystemContract) + copy(dAtA[i:], m.SystemContract) + i = encodeVarintTx(dAtA, i, uint64(len(m.SystemContract))) + i-- + dAtA[i] = 0x2a + } + if len(m.ConnectorZEVM) > 0 { + i -= len(m.ConnectorZEVM) + copy(dAtA[i:], m.ConnectorZEVM) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConnectorZEVM))) + i-- + dAtA[i] = 0x22 + } + if len(m.UniswapV2Router) > 0 { + i -= len(m.UniswapV2Router) + copy(dAtA[i:], m.UniswapV2Router) + i = encodeVarintTx(dAtA, i, uint64(len(m.UniswapV2Router))) + i-- + dAtA[i] = 0x1a + } + if len(m.Wzeta) > 0 { + i -= len(m.Wzeta) + copy(dAtA[i:], m.Wzeta) + i = encodeVarintTx(dAtA, i, uint64(len(m.Wzeta))) + i-- + dAtA[i] = 0x12 + } + if len(m.UniswapV2Factory) > 0 { + i -= len(m.UniswapV2Factory) + copy(dAtA[i:], m.UniswapV2Factory) + i = encodeVarintTx(dAtA, i, uint64(len(m.UniswapV2Factory))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgUpdateZRC20WithdrawFee) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1454,10 +1697,10 @@ func (m *MsgUpdateContractBytecode) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.NewBytecodeAddress) > 0 { - i -= len(m.NewBytecodeAddress) - copy(dAtA[i:], m.NewBytecodeAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewBytecodeAddress))) + if len(m.NewCodeHash) > 0 { + i -= len(m.NewCodeHash) + copy(dAtA[i:], m.NewCodeHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewCodeHash))) i-- dAtA[i] = 0x1a } @@ -1498,13 +1741,6 @@ func (m *MsgUpdateContractBytecodeResponse) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l - if len(m.NewBytecodeHash) > 0 { - i -= len(m.NewBytecodeHash) - copy(dAtA[i:], m.NewBytecodeHash) - i = encodeVarintTx(dAtA, i, uint64(len(m.NewBytecodeHash))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -1656,6 +1892,48 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgDeploySystemContracts) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeploySystemContractsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.UniswapV2Factory) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Wzeta) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.UniswapV2Router) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConnectorZEVM) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SystemContract) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgUpdateZRC20WithdrawFee) Size() (n int) { if m == nil { return 0 @@ -1802,7 +2080,7 @@ func (m *MsgUpdateContractBytecode) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.NewBytecodeAddress) + l = len(m.NewCodeHash) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1815,10 +2093,6 @@ func (m *MsgUpdateContractBytecodeResponse) Size() (n int) { } var l int _ = l - l = len(m.NewBytecodeHash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -1887,7 +2161,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgUpdateZRC20WithdrawFee) Unmarshal(dAtA []byte) error { +func (m *MsgDeploySystemContracts) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1910,10 +2184,10 @@ func (m *MsgUpdateZRC20WithdrawFee) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateZRC20WithdrawFee: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDeploySystemContracts: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateZRC20WithdrawFee: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDeploySystemContracts: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1948,24 +2222,316 @@ func (m *MsgUpdateZRC20WithdrawFee) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Address", wireType) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeploySystemContractsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeploySystemContractsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeploySystemContractsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UniswapV2Factory", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UniswapV2Factory = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Wzeta", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Wzeta = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UniswapV2Router", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UniswapV2Router = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConnectorZEVM", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConnectorZEVM = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SystemContract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SystemContract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateZRC20WithdrawFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateZRC20WithdrawFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateZRC20WithdrawFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } intStringLen := int(stringLen) if intStringLen < 0 { @@ -2878,7 +3444,7 @@ func (m *MsgUpdateContractBytecode) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewBytecodeAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewCodeHash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2906,7 +3472,7 @@ func (m *MsgUpdateContractBytecode) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NewBytecodeAddress = string(dAtA[iNdEx:postIndex]) + m.NewCodeHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2958,40 +3524,6 @@ func (m *MsgUpdateContractBytecodeResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgUpdateContractBytecodeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewBytecodeHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NewBytecodeHash = append(m.NewBytecodeHash[:0], dAtA[iNdEx:postIndex]...) - if m.NewBytecodeHash == nil { - m.NewBytecodeHash = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/observer/client/cli/cli_node_account.go b/x/observer/client/cli/cli_node_account.go index ae745e26a1..199cf87e70 100644 --- a/x/observer/client/cli/cli_node_account.go +++ b/x/observer/client/cli/cli_node_account.go @@ -44,7 +44,7 @@ func CmdListNodeAccount() *cobra.Command { func CmdShowNodeAccount() *cobra.Command { cmd := &cobra.Command{ - Use: "show-node-account [index]", + Use: "show-node-account [operator_address]", Short: "shows a NodeAccount", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/observer/client/cli/tx.go b/x/observer/client/cli/tx.go index 5b94a365a7..dd886894aa 100644 --- a/x/observer/client/cli/tx.go +++ b/x/observer/client/cli/tx.go @@ -26,6 +26,7 @@ func GetTxCmd() *cobra.Command { CmdUpdateCrosschainFlags(), CmdUpdateKeygen(), CmdAddBlameVote(), + CmdUpdateObserver(), CmdEncode(), ) diff --git a/x/observer/client/cli/tx_update_observer.go b/x/observer/client/cli/tx_update_observer.go new file mode 100644 index 0000000000..3eddcb9a25 --- /dev/null +++ b/x/observer/client/cli/tx_update_observer.go @@ -0,0 +1,63 @@ +package cli + +import ( + "strconv" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func CmdUpdateObserver() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-observer [old-observer-address] [new-observer-address] [update-reason]", + Short: "Broadcast message add-observer", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + updateReasonInt, err := strconv.ParseInt(args[2], 10, 32) + if err != nil { + return err + } + // #nosec G701 parsed in range + updateReason, err := parseUpdateReason(int32(updateReasonInt)) + if err != nil { + return err + } + msg := types.NewMsgUpdateObserver( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + updateReason, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func parseUpdateReason(i int32) (types.ObserverUpdateReason, error) { + if _, ok := types.ObserverUpdateReason_name[i]; ok { + switch i { + case 1: + return types.ObserverUpdateReason_Tombstoned, nil + case 2: + return types.ObserverUpdateReason_AdminUpdate, nil + } + } + return types.ObserverUpdateReason_Tombstoned, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid update reason") +} diff --git a/x/observer/keeper/hooks.go b/x/observer/keeper/hooks.go index e81f9c38aa..2659eeb95c 100644 --- a/x/observer/keeper/hooks.go +++ b/x/observer/keeper/hooks.go @@ -73,7 +73,6 @@ func (k Keeper) CleanSlashedValidator(ctx sdk.Context, valAddress sdk.ValAddress if !found { return types.ErrNotValidator } - accAddress, err := types.GetAccAddressFromOperatorAddress(valAddress.String()) if err != nil { return err diff --git a/x/observer/keeper/keeper.go b/x/observer/keeper/keeper.go index bb0d40e9c8..b8cb0378c3 100644 --- a/x/observer/keeper/keeper.go +++ b/x/observer/keeper/keeper.go @@ -14,11 +14,12 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace - stakingKeeper types.StakingKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + stakingKeeper types.StakingKeeper + slashingKeeper types.SlashingKeeper } ) @@ -28,6 +29,7 @@ func NewKeeper( memKey storetypes.StoreKey, ps paramtypes.Subspace, stakingKeeper types.StakingKeeper, + slashinKeeper types.SlashingKeeper, ) *Keeper { // set KeyTable if it has not already been set @@ -36,14 +38,23 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - stakingKeeper: stakingKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + stakingKeeper: stakingKeeper, + slashingKeeper: slashinKeeper, } } +func (k Keeper) GetSlashingKeeper() types.SlashingKeeper { + return k.slashingKeeper +} + +func (k Keeper) GetStakingKeeper() types.StakingKeeper { + return k.stakingKeeper +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/observer/keeper/keeper_test.go b/x/observer/keeper/keeper_test.go index f876c90563..7c13b7b0f2 100644 --- a/x/observer/keeper/keeper_test.go +++ b/x/observer/keeper/keeper_test.go @@ -3,6 +3,8 @@ package keeper import ( "testing" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/store" @@ -42,6 +44,7 @@ func SetupKeeper(t testing.TB) (*Keeper, sdk.Context) { memStoreKey, paramsSubspace, stakingkeeper.Keeper{}, + slashingkeeper.Keeper{}, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) diff --git a/x/observer/keeper/keeper_utils.go b/x/observer/keeper/keeper_utils.go index 8424985d31..a5a22bc36d 100644 --- a/x/observer/keeper/keeper_utils.go +++ b/x/observer/keeper/keeper_utils.go @@ -23,7 +23,7 @@ func (k Keeper) AddVoteToBallot(ctx sdk.Context, ballot types.Ballot, address st // This function with only return true if the ballot moves for pending to success or failed status with this vote. // If the ballot is already finalized in the previous vote , it will return false func (k Keeper) CheckIfFinalizingVote(ctx sdk.Context, ballot types.Ballot) (types.Ballot, bool) { - ballot, isFinalized := ballot.IsBallotFinalized() + ballot, isFinalized := ballot.IsFinalizingVote() if !isFinalized { return ballot, false } @@ -32,7 +32,20 @@ func (k Keeper) CheckIfFinalizingVote(ctx sdk.Context, ballot types.Ballot) (typ } // IsAuthorized checks whether a signer is authorized to sign , by checking their address against the observer mapper which contains the observer list for the chain and type +// It also checks if the signer is a validator and if they are not tombstoned func (k Keeper) IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) bool { + isPresentInMapper := k.IsObserverPresentInMappers(ctx, address, chain) + if !isPresentInMapper { + return false + } + isTombstoned, err := k.IsOperatorTombstoned(ctx, address) + if err != nil || isTombstoned { + return false + } + return true +} + +func (k Keeper) IsObserverPresentInMappers(ctx sdk.Context, address string, chain *common.Chain) bool { observerMapper, found := k.GetObserverMapper(ctx, chain) if !found { return false @@ -85,7 +98,23 @@ func (k Keeper) IsValidator(ctx sdk.Context, creator string) error { return types.ErrValidatorStatus } return nil +} + +func (k Keeper) IsOperatorTombstoned(ctx sdk.Context, creator string) (bool, error) { + valAddress, err := types.GetOperatorAddressFromAccAddress(creator) + if err != nil { + return false, err + } + validator, found := k.stakingKeeper.GetValidator(ctx, valAddress) + if !found { + return false, types.ErrNotValidator + } + consAddress, err := validator.GetConsAddr() + if err != nil { + return false, err + } + return k.slashingKeeper.IsTombstoned(ctx, consAddress), nil } func (k Keeper) CheckObserverDelegation(ctx sdk.Context, accAddress string, chain *common.Chain) error { diff --git a/x/observer/keeper/keeper_utils_test.go b/x/observer/keeper/keeper_utils_test.go new file mode 100644 index 0000000000..b5dc13f5ab --- /dev/null +++ b/x/observer/keeper/keeper_utils_test.go @@ -0,0 +1,106 @@ +package keeper_test + +import ( + "math/rand" + "testing" + "time" + + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/stretchr/testify/assert" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestKeeper_IsAuthorized(t *testing.T) { + t.Run("authorized observer", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + chains := k.GetParams(ctx).GetSupportedChains() + + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + k.GetStakingKeeper().SetValidator(ctx, validator) + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: false, + MissedBlocksCounter: 1, + }) + + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + } + for _, chain := range chains { + assert.True(t, k.IsAuthorized(ctx, accAddressOfValidator.String(), chain)) + } + }) + t.Run("not authorized for tombstoned observer", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + chains := k.GetParams(ctx).GetSupportedChains() + + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + k.GetStakingKeeper().SetValidator(ctx, validator) + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + } + for _, chain := range chains { + assert.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String(), chain)) + } + }) + t.Run("not authorized for non-validator observer", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + chains := k.GetParams(ctx).GetSupportedChains() + + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: false, + MissedBlocksCounter: 1, + }) + + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + } + for _, chain := range chains { + assert.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String(), chain)) + } + }) +} diff --git a/x/observer/keeper/msg_server_add_block_header.go b/x/observer/keeper/msg_server_add_block_header.go index 76a17801f1..ef93cb42cb 100644 --- a/x/observer/keeper/msg_server_add_block_header.go +++ b/x/observer/keeper/msg_server_add_block_header.go @@ -28,10 +28,10 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH return nil, fmt.Errorf("block header verification flags not found") } if common.IsBitcoinChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { - return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerficationDisabled, "proof verification not enabled for bitcoin ,chain id: %d", msg.ChainId) + return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for bitcoin ,chain id: %d", msg.ChainId) } if common.IsEVMChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { - return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerficationDisabled, "proof verification not enabled for evm ,chain id: %d", msg.ChainId) + return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for evm ,chain id: %d", msg.ChainId) } _, found = k.GetBlockHeader(ctx, msg.BlockHash) diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go index c33b169c33..eb2c93970f 100644 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ b/x/observer/keeper/msg_server_add_block_header_test.go @@ -1,11 +1,10 @@ -//go:build TESTNET -// +build TESTNET - package keeper_test import ( + "math/rand" "testing" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -27,55 +26,62 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { header3RLP, err := rlp.EncodeToBytes(header3) assert.NoError(t, err) - observerChain := common.GoerliChain() - observerAddress := sample.AccAddress() + observerChain := common.GoerliLocalnetChain() + r := rand.New(rand.NewSource(9)) + validator := sample.Validator(t, r) + observerAddress, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) // Add tests for btc headers : https://github.com/zeta-chain/node/issues/1336 tt := []struct { name string msg *types.MsgAddBlockHeader IsEthTypeChainEnabled bool IsBtcTypeChainEnabled bool + validator stakingtypes.Validator wantErr require.ErrorAssertionFunc }{ { name: "success submit eth header", msg: &types.MsgAddBlockHeader{ - Creator: observerAddress, - ChainId: common.GoerliChain().ChainId, + Creator: observerAddress.String(), + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, Header: common.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: require.NoError, }, { name: "failure submit eth header eth disabled", msg: &types.MsgAddBlockHeader{ - Creator: observerAddress, - ChainId: common.GoerliChain().ChainId, + Creator: observerAddress.String(), + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, Header: common.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { - assert.ErrorIs(t, err, types.ErrBlockHeaderVerficationDisabled) + assert.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }, }, { name: "failure submit eth header eth disabled", msg: &types.MsgAddBlockHeader{ Creator: sample.AccAddress(), - ChainId: common.GoerliChain().ChainId, + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, Header: common.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }, @@ -83,14 +89,15 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { { name: "should fail if block header parent does not exist", msg: &types.MsgAddBlockHeader{ - Creator: observerAddress, - ChainId: common.GoerliChain().ChainId, + Creator: observerAddress.String(), + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header3.Hash().Bytes(), Height: 3, Header: common.NewEthereumHeader(header3RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { require.Error(t, err) }, @@ -98,27 +105,29 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { { name: "should succeed if block header parent does exist", msg: &types.MsgAddBlockHeader{ - Creator: observerAddress, - ChainId: common.GoerliChain().ChainId, + Creator: observerAddress.String(), + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header2.Hash().Bytes(), Height: 2, Header: common.NewEthereumHeader(header2RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: require.NoError, }, { name: "should succeed to post 3rd header if 2nd header is posted", msg: &types.MsgAddBlockHeader{ - Creator: observerAddress, - ChainId: common.GoerliChain().ChainId, + Creator: observerAddress.String(), + ChainId: common.GoerliLocalnetChain().ChainId, BlockHash: header3.Hash().Bytes(), Height: 3, Header: common.NewEthereumHeader(header3RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, + validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { require.Error(t, err) }, @@ -130,8 +139,9 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { srv := keeper.NewMsgServerImpl(*k) k.SetObserverMapper(ctx, &types.ObserverMapper{ ObserverChain: &observerChain, - ObserverList: []string{observerAddress}, + ObserverList: []string{observerAddress.String()}, }) + k.GetStakingKeeper().SetValidator(ctx, tc.validator) k.SetCrosschainFlags(ctx, types.CrosschainFlags{ IsInboundEnabled: true, IsOutboundEnabled: true, diff --git a/x/observer/keeper/msg_server_add_observer.go b/x/observer/keeper/msg_server_add_observer.go new file mode 100644 index 0000000000..d15da59040 --- /dev/null +++ b/x/observer/keeper/msg_server_add_observer.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "context" + "math" + + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func (k msgServer) AddObserver(goCtx context.Context, msg *types.MsgAddObserver) (*types.MsgAddObserverResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg.Creator != k.GetParams(ctx).GetAdminPolicyAccount(types.Policy_Type_group2) { + return &types.MsgAddObserverResponse{}, types.ErrNotAuthorizedPolicy + } + pubkey, err := common.NewPubKey(msg.ZetaclientGranteePubkey) + if err != nil { + return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) + } + granteeAddress, err := common.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) + if err != nil { + return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) + } + k.DisableInboundOnly(ctx) + // AddNodeAccountOnly flag usage + // True: adds observer into the Node Account list but returns without adding to the observer list + // False: adds observer to the observer list, and not the node account list + // Inbound is disabled in both cases and needs to be enabled manually using an admin TX + if msg.AddNodeAccountOnly { + pubkeySet := common.PubKeySet{Secp256k1: pubkey, Ed25519: ""} + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: msg.ObserverAddress, + GranteeAddress: granteeAddress.String(), + GranteePubkey: &pubkeySet, + NodeStatus: types.NodeStatus_Active, + }) + k.SetKeygen(ctx, types.Keygen{BlockNumber: math.MaxInt64}) + return &types.MsgAddObserverResponse{}, nil + } + + observerMappers := k.GetAllObserverMappers(ctx) + totalObserverCountCurrentBlock := uint64(0) + for _, mapper := range observerMappers { + mapper.ObserverList = append(mapper.ObserverList, msg.ObserverAddress) + totalObserverCountCurrentBlock += uint64(len(mapper.ObserverList)) + k.SetObserverMapper(ctx, mapper) + } + k.SetLastObserverCount(ctx, &types.LastObserverCount{Count: totalObserverCountCurrentBlock}) + EmitEventAddObserver(ctx, totalObserverCountCurrentBlock, msg.ObserverAddress, granteeAddress.String(), msg.ZetaclientGranteePubkey) + return &types.MsgAddObserverResponse{}, nil +} diff --git a/x/observer/keeper/msg_server_update_observer.go b/x/observer/keeper/msg_server_update_observer.go new file mode 100644 index 0000000000..03c4dd6156 --- /dev/null +++ b/x/observer/keeper/msg_server_update_observer.go @@ -0,0 +1,100 @@ +package keeper + +import ( + "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func (k msgServer) UpdateObserver(goCtx context.Context, msg *types.MsgUpdateObserver) (*types.MsgUpdateObserverResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + ok, err := k.CheckUpdateReason(ctx, msg) + if err != nil { + return nil, errorsmod.Wrap(types.ErrUpdateObserver, err.Error()) + } + if !ok { + return nil, errorsmod.Wrap(types.ErrUpdateObserver, fmt.Sprintf("Unable to update observer with update reason : %s", msg.UpdateReason)) + } + + chains := k.GetParams(ctx).GetSupportedChains() + for _, chain := range chains { + if !k.IsObserverPresentInMappers(ctx, msg.OldObserverAddress, chain) { + return nil, errorsmod.Wrap(types.ErrNotAuthorized, fmt.Sprintf("Observer address is not authorized for chain : %s", chain.String())) + } + } + + err = k.IsValidator(ctx, msg.NewObserverAddress) + if err != nil { + return nil, errorsmod.Wrap(types.ErrUpdateObserver, err.Error()) + } + + // Update all mappers so that ballots can be created for the new observer address + k.UpdateObserverAddress(ctx, msg.OldObserverAddress, msg.NewObserverAddress) + + // Update the node account with the new operator address + nodeAccount, found := k.GetNodeAccount(ctx, msg.OldObserverAddress) + if !found { + return nil, errorsmod.Wrap(types.ErrNodeAccountNotFound, fmt.Sprintf("Observer node account not found : %s", msg.OldObserverAddress)) + } + newNodeAccount := nodeAccount + newNodeAccount.Operator = msg.NewObserverAddress + + // Remove an old node account, so that number of node accounts remains the same as the number of observers in the system + k.RemoveNodeAccount(ctx, msg.OldObserverAddress) + k.SetNodeAccount(ctx, newNodeAccount) + + // Check LastBlockObserver count just to be safe + observerMappers := k.GetAllObserverMappers(ctx) + totalObserverCountCurrentBlock := uint64(0) + for _, mapper := range observerMappers { + totalObserverCountCurrentBlock += uint64(len(mapper.ObserverList)) + } + lastBlockCount, found := k.GetLastObserverCount(ctx) + if !found { + return nil, errorsmod.Wrap(types.ErrLastObserverCountNotFound, fmt.Sprintf("Observer count not found")) + } + if lastBlockCount.Count != totalObserverCountCurrentBlock { + return nil, errorsmod.Wrap(types.ErrUpdateObserver, fmt.Sprintf("Observer count mismatch")) + } + return &types.MsgUpdateObserverResponse{}, nil +} + +func (k Keeper) CheckUpdateReason(ctx sdk.Context, msg *types.MsgUpdateObserver) (bool, error) { + switch msg.UpdateReason { + case types.ObserverUpdateReason_Tombstoned: + { + if msg.Creator != msg.OldObserverAddress { + return false, errorsmod.Wrap(types.ErrUpdateObserver, fmt.Sprintf("Creator address and old observer address need to be same for updating tombstoned observer")) + } + return k.IsOperatorTombstoned(ctx, msg.Creator) + } + case types.ObserverUpdateReason_AdminUpdate: + { + if msg.Creator != k.GetParams(ctx).GetAdminPolicyAccount(types.Policy_Type_group2) { + return false, types.ErrNotAuthorizedPolicy + } + return true, nil + } + } + return false, nil +} + +func (k Keeper) UpdateObserverAddress(ctx sdk.Context, oldObserverAddress, newObserverAddress string) { + observerMappers := k.GetAllObserverMappers(ctx) + for _, om := range observerMappers { + UpdateObserverList(om.ObserverList, oldObserverAddress, newObserverAddress) + k.SetObserverMapper(ctx, om) + } +} + +func UpdateObserverList(list []string, oldObserverAddresss, newObserverAddress string) { + for i, observer := range list { + if observer == oldObserverAddresss { + list[i] = newObserverAddress + } + } +} diff --git a/x/observer/keeper/msg_server_update_observer_test.go b/x/observer/keeper/msg_server_update_observer_test.go new file mode 100644 index 0000000000..44048f4200 --- /dev/null +++ b/x/observer/keeper/msg_server_update_observer_test.go @@ -0,0 +1,554 @@ +package keeper_test + +import ( + "math/rand" + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/assert" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/keeper" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestMsgServer_UpdateObserver(t *testing.T) { + t.Run("successfully update tombstoned observer", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: accAddressOfValidator.String(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.NoError(t, err) + acc, found := k.GetNodeAccount(ctx, newOperatorAddress.String()) + assert.True(t, found) + assert.Equal(t, newOperatorAddress.String(), acc.Operator) + }) + + t.Run("unable to update to a non validator address", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: accAddressOfValidator.String(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.ErrorIs(t, err, types.ErrUpdateObserver) + }) + + t.Run("unable to update tombstoned validator with with non operator account", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.ErrorIs(t, err, types.ErrUpdateObserver) + }) + t.Run("unable to update non-tombstoned observer with update reason tombstoned", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: false, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: accAddressOfValidator.String(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.ErrorIs(t, err, types.ErrUpdateObserver) + }) + t.Run("unable to update observer with no node account", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: accAddressOfValidator.String(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.ErrorIs(t, err, types.ErrNodeAccountNotFound) + }) + t.Run("unable to update observer when last observer count is missing", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: true, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: accAddressOfValidator.String(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }) + assert.ErrorIs(t, err, types.ErrLastObserverCountNotFound) + }) + t.Run("update observer using admin policy", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + setAdminCrossChainFlags(ctx, k, admin, types.Policy_Type_group2) + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: false, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: admin, + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }) + assert.NoError(t, err) + acc, found := k.GetNodeAccount(ctx, newOperatorAddress.String()) + assert.True(t, found) + assert.Equal(t, newOperatorAddress.String(), acc.Operator) + }) + t.Run("fail to update observer using regular account and update type admin", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + + // #nosec G404 test purpose - weak randomness is not an issue here + r := rand.New(rand.NewSource(9)) + + // Set validator in the store + validator := sample.Validator(t, r) + validatorNew := sample.Validator(t, r) + validatorNew.Status = stakingtypes.Bonded + k.GetStakingKeeper().SetValidator(ctx, validatorNew) + k.GetStakingKeeper().SetValidator(ctx, validator) + + consAddress, err := validator.GetConsAddr() + assert.NoError(t, err) + k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ + Address: consAddress.String(), + StartHeight: 0, + JailedUntil: ctx.BlockHeader().Time.Add(1000000 * time.Second), + Tombstoned: false, + MissedBlocksCounter: 1, + }) + + chains := k.GetParams(ctx).GetSupportedChains() + accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) + assert.NoError(t, err) + count := uint64(0) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: []string{accAddressOfValidator.String()}, + }) + count += 1 + } + + k.SetNodeAccount(ctx, types.NodeAccount{ + Operator: accAddressOfValidator.String(), + }) + + newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) + assert.NoError(t, err) + + k.SetLastObserverCount(ctx, &types.LastObserverCount{ + Count: count, + }) + + _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: accAddressOfValidator.String(), + NewObserverAddress: newOperatorAddress.String(), + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }) + assert.ErrorIs(t, err, types.ErrUpdateObserver) + }) +} + +func TestUpdateObserverList(t *testing.T) { + t.Run("update observer list", func(t *testing.T) { + oldObserverAddress := sample.AccAddress() + newObserverAddress := sample.AccAddress() + list := []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), oldObserverAddress} + assert.Equal(t, oldObserverAddress, list[3]) + keeper.UpdateObserverList(list, oldObserverAddress, newObserverAddress) + assert.Equal(t, 4, len(list)) + assert.Equal(t, newObserverAddress, list[3]) + }) +} + +func TestKeeper_UpdateObserverAddress(t *testing.T) { + t.Run("update observer address", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + oldObserverAddress := sample.AccAddress() + newObserverAddress := sample.AccAddress() + chains := k.GetParams(ctx).GetSupportedChains() + observerList := CreateRandomObserverList(10, oldObserverAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: observerList, + }) + } + k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) + observerMappers := k.GetAllObserverMappers(ctx) + for _, om := range observerMappers { + assert.Equal(t, len(observerList), len(om.ObserverList)) + assert.Equal(t, newObserverAddress, om.ObserverList[len(om.ObserverList)-1]) + } + }) + t.Run("update observer address long observerList", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + oldObserverAddress := sample.AccAddress() + newObserverAddress := sample.AccAddress() + chains := k.GetParams(ctx).GetSupportedChains() + observerList := CreateRandomObserverList(1000, oldObserverAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: observerList, + }) + } + k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) + observerMappers := k.GetAllObserverMappers(ctx) + for _, om := range observerMappers { + assert.Equal(t, len(observerList), len(om.ObserverList)) + assert.Equal(t, newObserverAddress, om.ObserverList[len(om.ObserverList)-1]) + } + }) + t.Run("update observer address super long observerList", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + oldObserverAddress := sample.AccAddress() + newObserverAddress := sample.AccAddress() + chains := k.GetParams(ctx).GetSupportedChains() + observerList := CreateRandomObserverList(100000, oldObserverAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: observerList, + }) + } + k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) + observerMappers := k.GetAllObserverMappers(ctx) + for _, om := range observerMappers { + assert.Equal(t, len(observerList), len(om.ObserverList)) + assert.Equal(t, newObserverAddress, om.ObserverList[len(om.ObserverList)-1]) + } + }) + t.Run("update observer address short observerList", func(t *testing.T) { + k, ctx := keepertest.ObserverKeeper(t) + oldObserverAddress := sample.AccAddress() + newObserverAddress := sample.AccAddress() + chains := k.GetParams(ctx).GetSupportedChains() + observerList := CreateRandomObserverList(1, oldObserverAddress) + for _, chain := range chains { + k.SetObserverMapper(ctx, &types.ObserverMapper{ + ObserverChain: chain, + ObserverList: observerList, + }) + } + k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) + observerMappers := k.GetAllObserverMappers(ctx) + for _, om := range observerMappers { + assert.Equal(t, len(observerList), len(om.ObserverList)) + assert.Equal(t, newObserverAddress, om.ObserverList[len(om.ObserverList)-1]) + } + }) +} + +func CreateRandomObserverList(maxLen int, observerAddress string) []string { + r := rand.New(rand.NewSource(9)) + list := make([]string, r.Intn(maxLen)+1) + for i := range list { + list[i] = sample.AccAddress() + } + list = append(list, observerAddress) + return list +} diff --git a/x/observer/keeper/observer_mapper.go b/x/observer/keeper/observer_mapper.go index e3c2e58d06..ca42fb3618 100644 --- a/x/observer/keeper/observer_mapper.go +++ b/x/observer/keeper/observer_mapper.go @@ -3,13 +3,9 @@ package keeper import ( "context" "fmt" - "math" - - cosmoserrors "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" @@ -91,47 +87,6 @@ func (k Keeper) GetAllObserverMappersForAddress(ctx sdk.Context, address string) // AddObserver adds in a new observer to the store.It can be executed using an admin policy account // Once added, the function also resets keygen and pauses inbound so that a new TSS can be generated. -func (k msgServer) AddObserver(goCtx context.Context, msg *types.MsgAddObserver) (*types.MsgAddObserverResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - if msg.Creator != k.GetParams(ctx).GetAdminPolicyAccount(types.Policy_Type_group2) { - return &types.MsgAddObserverResponse{}, types.ErrNotAuthorizedPolicy - } - pubkey, err := common.NewPubKey(msg.ZetaclientGranteePubkey) - if err != nil { - return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) - } - granteeAddress, err := common.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) - if err != nil { - return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) - } - k.DisableInboundOnly(ctx) - // AddNodeAccountOnly flag usage - // True: adds observer into the Node Account list but returns without adding to the observer list - // False: adds observer to the observer list, and not the node account list - // Inbound is disabled in both cases and needs to be enabled manually using an admin TX - if msg.AddNodeAccountOnly { - pubkeySet := common.PubKeySet{Secp256k1: pubkey, Ed25519: ""} - k.SetNodeAccount(ctx, types.NodeAccount{ - Operator: msg.ObserverAddress, - GranteeAddress: granteeAddress.String(), - GranteePubkey: &pubkeySet, - NodeStatus: types.NodeStatus_Active, - }) - k.SetKeygen(ctx, types.Keygen{BlockNumber: math.MaxInt64}) - return &types.MsgAddObserverResponse{}, nil - } - - observerMappers := k.GetAllObserverMappers(ctx) - totalObserverCountCurrentBlock := uint64(0) - for _, mapper := range observerMappers { - mapper.ObserverList = append(mapper.ObserverList, msg.ObserverAddress) - totalObserverCountCurrentBlock += uint64(len(mapper.ObserverList)) - k.SetObserverMapper(ctx, mapper) - } - k.SetLastObserverCount(ctx, &types.LastObserverCount{Count: totalObserverCountCurrentBlock}) - EmitEventAddObserver(ctx, totalObserverCountCurrentBlock, msg.ObserverAddress, granteeAddress.String(), msg.ZetaclientGranteePubkey) - return &types.MsgAddObserverResponse{}, nil -} //Queries diff --git a/x/observer/keeper/observer_mapper_test.go b/x/observer/keeper/observer_mapper_test.go index eb861934ad..12e572e81a 100644 --- a/x/observer/keeper/observer_mapper_test.go +++ b/x/observer/keeper/observer_mapper_test.go @@ -1,7 +1,4 @@ -//go:build PRIVNET -// +build PRIVNET - -package keeper +package keeper_test import ( "testing" @@ -9,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -102,11 +100,11 @@ func TestKeeper_GetObserver(t *testing.T) { for _, test := range tt { test := test t.Run(test.name, func(t *testing.T) { - keeper, ctx := SetupKeeper(t) + k, ctx := keepertest.ObserverKeeper(t) for _, mapper := range test.mapper { - keeper.SetObserverMapper(ctx, mapper) + k.SetObserverMapper(ctx, mapper) } - mapper, found := keeper.GetObserverMapper(ctx, test.assertChain) + mapper, found := k.GetObserverMapper(ctx, test.assertChain) assert.Equal(t, test.isFound, found) if test.isFound { assert.Equal(t, test.assertObsListLen, len(mapper.ObserverList)) @@ -139,14 +137,14 @@ func TestKeeper_ObserversByChainAndType(t *testing.T) { { name: "Filter out from multiple mappers", mapper: append(append(types.CreateObserverMapperList(1, common.GoerliChain()), - types.CreateObserverMapperList(1, common.ZetaChain())...)), + types.CreateObserverMapperList(1, common.ZetaPrivnetChain())...)), assertChain: common.ChainName_goerli_localnet, isFound: true, }, { name: "No Observers of expected Observation Chain", mapper: append(append(types.CreateObserverMapperList(1, common.GoerliChain()), - types.CreateObserverMapperList(1, common.ZetaChain())...)), + types.CreateObserverMapperList(1, common.ZetaPrivnetChain())...)), assertChain: common.ChainName_btc_regtest, isFound: false, }, @@ -155,16 +153,17 @@ func TestKeeper_ObserversByChainAndType(t *testing.T) { for _, test := range tt { test := test t.Run(test.name, func(t *testing.T) { - keeper, ctx := SetupKeeper(t) + k, ctx := keepertest.ObserverKeeper(t) + for _, mapper := range test.mapper { - keeper.SetObserverMapper(ctx, mapper) + k.SetObserverMapper(ctx, mapper) } goCtx := sdk.WrapSDKContext(ctx) msg := &types.QueryObserversByChainRequest{ ObservationChain: test.assertChain.String(), } - mapper, _ := keeper.ObserversByChain(goCtx, msg) + mapper, _ := k.ObserversByChain(goCtx, msg) if test.isFound { assert.NotEqual(t, "", mapper) } @@ -186,10 +185,10 @@ func TestKeeper_GetAllObserverAddresses(t *testing.T) { ChainName: common.ChainName_bsc_mainnet, ChainId: 5, })...) - keeper, ctx := SetupKeeper(t) + k, ctx := keepertest.ObserverKeeper(t) for _, mapper := range mappers { - keeper.SetObserverMapper(ctx, mapper) + k.SetObserverMapper(ctx, mapper) } - addresses := keeper.GetAllObserverAddresses(ctx) + addresses := k.GetAllObserverAddresses(ctx) assert.Equal(t, 4, len(addresses)) } diff --git a/x/observer/module_simulation.go b/x/observer/module_simulation.go index 08b52bcc08..5ebd6a9027 100644 --- a/x/observer/module_simulation.go +++ b/x/observer/module_simulation.go @@ -9,7 +9,6 @@ import ( "github.com/zeta-chain/zetacore/x/observer/types" ) -/* #nosec */ const ( // #nosec G101 not a hardcoded credential opWeightMsgUpdateClientParams = "op_weight_msg_update_client_params" diff --git a/x/observer/types/ballot.go b/x/observer/types/ballot.go index dae3476789..bc6bfd66ee 100644 --- a/x/observer/types/ballot.go +++ b/x/observer/types/ballot.go @@ -34,12 +34,18 @@ func (m Ballot) GetVoterIndex(address string) int { return index } -func (m Ballot) IsBallotFinalized() (Ballot, bool) { +// Is finalzing vote checks sets the ballot to a final status if enough votes have been added +// If it has already been finalized it returns false +// It enough votes have not been added it returns false +func (m Ballot) IsFinalizingVote() (Ballot, bool) { if m.BallotStatus != BallotStatus_BallotInProgress { return m, false } success, failure := sdk.ZeroDec(), sdk.ZeroDec() total := sdk.NewDec(int64(len(m.VoterList))) + if total.IsZero() { + return m, false + } for _, vote := range m.Votes { if vote == VoteType_SuccessObservation { success = success.Add(sdk.OneDec()) @@ -55,6 +61,7 @@ func (m Ballot) IsBallotFinalized() (Ballot, bool) { return m, true } } + if success.IsPositive() { if success.Quo(total).GTE(m.BallotThreshold) { m.BallotStatus = BallotStatus_BallotFinalized_SuccessObservation diff --git a/x/observer/types/ballot_test.go b/x/observer/types/ballot_test.go index 008df06f11..0e087309e3 100644 --- a/x/observer/types/ballot_test.go +++ b/x/observer/types/ballot_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestVoter_IsBallotFinalized(t *testing.T) { +func TestBallot_AddVote(t *testing.T) { type votes struct { address string vote VoteType @@ -66,9 +66,76 @@ func TestVoter_IsBallotFinalized(t *testing.T) { finalStatus: BallotStatus_BallotInProgress, isFinalized: false, }, - { - name: "Two observers ", + name: "Ballot finalized at threshold", + threshold: sdk.MustNewDecFromStr("0.66"), + voterList: []string{"Observer1", "Observer2", "Observer3", "Observer4", "Observer5", "Observer6", "Observer7", "Observer8", "Observer9", "Observer10", "Observer11", "Observer12"}, + votes: []votes{ + {"Observer1", VoteType_SuccessObservation}, + {"Observer2", VoteType_SuccessObservation}, + {"Observer3", VoteType_SuccessObservation}, + {"Observer4", VoteType_SuccessObservation}, + {"Observer5", VoteType_SuccessObservation}, + {"Observer6", VoteType_SuccessObservation}, + {"Observer7", VoteType_SuccessObservation}, + {"Observer8", VoteType_SuccessObservation}, + {"Observer9", VoteType_NotYetVoted}, + {"Observer10", VoteType_NotYetVoted}, + {"Observer11", VoteType_NotYetVoted}, + {"Observer12", VoteType_NotYetVoted}, + }, + finalVotes: []VoteType{VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + }, + finalStatus: BallotStatus_BallotFinalized_SuccessObservation, + isFinalized: true, + }, + { + name: "Ballot finalized at threshold but more votes added after", + threshold: sdk.MustNewDecFromStr("0.66"), + voterList: []string{"Observer1", "Observer2", "Observer3", "Observer4", "Observer5", "Observer6", "Observer7", "Observer8", "Observer9", "Observer10", "Observer11", "Observer12"}, + votes: []votes{ + {"Observer1", VoteType_SuccessObservation}, + {"Observer2", VoteType_SuccessObservation}, + {"Observer3", VoteType_SuccessObservation}, + {"Observer4", VoteType_SuccessObservation}, + {"Observer5", VoteType_SuccessObservation}, + {"Observer6", VoteType_SuccessObservation}, + {"Observer7", VoteType_SuccessObservation}, + {"Observer8", VoteType_SuccessObservation}, + {"Observer9", VoteType_SuccessObservation}, + {"Observer10", VoteType_SuccessObservation}, + {"Observer11", VoteType_SuccessObservation}, + {"Observer12", VoteType_SuccessObservation}, + }, + finalVotes: []VoteType{VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + }, + finalStatus: BallotStatus_BallotFinalized_SuccessObservation, + isFinalized: true, + }, + { + name: "Two observers", threshold: sdk.MustNewDecFromStr("1.00"), voterList: []string{"Observer1", "Observer2"}, votes: []votes{ @@ -79,6 +146,48 @@ func TestVoter_IsBallotFinalized(t *testing.T) { finalStatus: BallotStatus_BallotFinalized_SuccessObservation, isFinalized: true, }, + { + name: "Low threshold 1 always fails as Failure is checked first", + threshold: sdk.MustNewDecFromStr("0.01"), + voterList: []string{"Observer1", "Observer2", "Observer3", "Observer4"}, + votes: []votes{ + {"Observer1", VoteType_SuccessObservation}, + {"Observer2", VoteType_SuccessObservation}, + {"Observer3", VoteType_SuccessObservation}, + {"Observer4", VoteType_FailureObservation}, + }, + finalVotes: []VoteType{VoteType_SuccessObservation, VoteType_SuccessObservation, VoteType_SuccessObservation, VoteType_FailureObservation}, + finalStatus: BallotStatus_BallotFinalized_FailureObservation, + isFinalized: true, + }, + { + name: "Low threshold 2 always fails as Failure is checked first", + threshold: sdk.MustNewDecFromStr("0.01"), + voterList: []string{"Observer1", "Observer2", "Observer3", "Observer4"}, + votes: []votes{ + {"Observer1", VoteType_SuccessObservation}, + {"Observer2", VoteType_FailureObservation}, + {"Observer3", VoteType_SuccessObservation}, + {"Observer4", VoteType_SuccessObservation}, + }, + finalVotes: []VoteType{VoteType_SuccessObservation, VoteType_FailureObservation, VoteType_SuccessObservation, VoteType_SuccessObservation}, + finalStatus: BallotStatus_BallotFinalized_FailureObservation, + isFinalized: true, + }, + { + name: "100 percent threshold cannot finalze with less than 100 percent votes", + threshold: sdk.MustNewDecFromStr("1"), + voterList: []string{"Observer1", "Observer2", "Observer3", "Observer4"}, + votes: []votes{ + {"Observer1", VoteType_SuccessObservation}, + {"Observer2", VoteType_FailureObservation}, + {"Observer3", VoteType_SuccessObservation}, + {"Observer4", VoteType_SuccessObservation}, + }, + finalVotes: []VoteType{VoteType_SuccessObservation, VoteType_FailureObservation, VoteType_SuccessObservation, VoteType_SuccessObservation}, + finalStatus: BallotStatus_BallotInProgress, + isFinalized: false, + }, } for _, test := range tt { test := test @@ -96,7 +205,7 @@ func TestVoter_IsBallotFinalized(t *testing.T) { ballot, _ = ballot.AddVote(vote.address, vote.vote) } - finalBallot, isFinalized := ballot.IsBallotFinalized() + finalBallot, isFinalized := ballot.IsFinalizingVote() assert.Equal(t, test.finalStatus, finalBallot.BallotStatus) assert.Equal(t, test.finalVotes, finalBallot.Votes) assert.Equal(t, test.isFinalized, isFinalized) @@ -104,6 +213,137 @@ func TestVoter_IsBallotFinalized(t *testing.T) { } } +func TestBallot_IsFinalizingVote(t *testing.T) { + tt := []struct { + name string + BallotThreshold sdk.Dec + Votes []VoteType + finalizingVote int + finalStatus BallotStatus + }{ + { + name: "finalized to success", + BallotThreshold: sdk.MustNewDecFromStr("0.66"), + Votes: []VoteType{ + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_SuccessObservation, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + }, + finalizingVote: 7, + finalStatus: BallotStatus_BallotFinalized_SuccessObservation, + }, + { + name: "finalized to failure", + BallotThreshold: sdk.MustNewDecFromStr("0.66"), + Votes: []VoteType{ + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + }, + finalizingVote: 7, + finalStatus: BallotStatus_BallotFinalized_FailureObservation, + }, + { + name: "low threshold finalized early to success", + BallotThreshold: sdk.MustNewDecFromStr("0.01"), + Votes: []VoteType{ + VoteType_SuccessObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + VoteType_NotYetVoted, + }, + finalizingVote: 0, + finalStatus: BallotStatus_BallotFinalized_SuccessObservation, + }, + { + name: "100 percent threshold cannot finalize with less than 100 percent votes", + BallotThreshold: sdk.MustNewDecFromStr("1"), + Votes: []VoteType{ + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_SuccessObservation, + }, + finalizingVote: 0, + finalStatus: BallotStatus_BallotInProgress, + }, + { + name: "100 percent threshold can finalize with 100 percent votes", + BallotThreshold: sdk.MustNewDecFromStr("1"), + Votes: []VoteType{ + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + VoteType_FailureObservation, + }, + finalizingVote: 11, + finalStatus: BallotStatus_BallotFinalized_FailureObservation, + }, + } + for _, test := range tt { + test := test + t.Run(test.name, func(t *testing.T) { + + ballot := Ballot{ + BallotStatus: BallotStatus_BallotInProgress, + BallotThreshold: test.BallotThreshold, + VoterList: make([]string, len(test.Votes)), + } + isFinalizingVote := false + for index, vote := range test.Votes { + ballot.Votes = append(ballot.Votes, vote) + ballot, isFinalizingVote = ballot.IsFinalizingVote() + if isFinalizingVote { + assert.Equal(t, test.finalizingVote, index) + } + } + assert.Equal(t, test.finalStatus, ballot.BallotStatus) + }) + } +} + func Test_BuildRewardsDistribution(t *testing.T) { tt := []struct { name string diff --git a/x/observer/types/codec.go b/x/observer/types/codec.go index 3d30bbc3a7..c6add9ed17 100644 --- a/x/observer/types/codec.go +++ b/x/observer/types/codec.go @@ -14,6 +14,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateCrosschainFlags{}, "crosschain/UpdateCrosschainFlags", nil) cdc.RegisterConcrete(&MsgUpdateKeygen{}, "crosschain/UpdateKeygen", nil) cdc.RegisterConcrete(&MsgAddBlockHeader{}, "crosschain/AddBlockHeader", nil) + cdc.RegisterConcrete(&MsgUpdateObserver{}, "observer/UpdateObserver", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -24,6 +25,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateCrosschainFlags{}, &MsgUpdateKeygen{}, &MsgAddBlockHeader{}, + &MsgUpdateObserver{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/observer/types/core_params.go b/x/observer/types/core_params.go new file mode 100644 index 0000000000..adf29d74ea --- /dev/null +++ b/x/observer/types/core_params.go @@ -0,0 +1,156 @@ +package types + +import ( + "fmt" + + "github.com/zeta-chain/zetacore/common" +) + +// GetCoreParams returns a list of default core params +func GetCoreParams() CoreParamsList { + return CoreParamsList{ + CoreParams: []*CoreParams{ + { + ChainId: common.EthChain().ChainId, + ConfirmationCount: 14, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + InTxTicker: 12, + OutTxTicker: 15, + WatchUtxoTicker: 0, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.BscMainnetChain().ChainId, + ConfirmationCount: 14, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + InTxTicker: 5, + OutTxTicker: 15, + WatchUtxoTicker: 0, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.BtcMainnetChain().ChainId, + ConfirmationCount: 2, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + WatchUtxoTicker: 30, + InTxTicker: 120, + OutTxTicker: 60, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.GoerliChain().ChainId, + ConfirmationCount: 6, + // This is the actual Zeta token Goerli testnet, we need to specify this address for the integration tests to pass + ZetaTokenContractAddress: "0x0000c304d2934c00db1d51995b9f6996affd17c0", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + InTxTicker: 12, + OutTxTicker: 15, + WatchUtxoTicker: 0, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.BscTestnetChain().ChainId, + ConfirmationCount: 6, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + InTxTicker: 5, + OutTxTicker: 15, + WatchUtxoTicker: 0, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.MumbaiChain().ChainId, + ConfirmationCount: 12, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + InTxTicker: 2, + OutTxTicker: 15, + WatchUtxoTicker: 0, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 60, + }, + { + ChainId: common.BtcTestNetChain().ChainId, + ConfirmationCount: 2, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + WatchUtxoTicker: 30, + InTxTicker: 120, + OutTxTicker: 12, + GasPriceTicker: 30, + OutboundTxScheduleInterval: 30, + OutboundTxScheduleLookahead: 100, + }, + { + ChainId: common.BtcRegtestChain().ChainId, + ConfirmationCount: 2, + ZetaTokenContractAddress: "", + ConnectorContractAddress: "", + Erc20CustodyContractAddress: "", + GasPriceTicker: 5, + WatchUtxoTicker: 1, + InTxTicker: 1, + OutTxTicker: 2, + OutboundTxScheduleInterval: 2, + OutboundTxScheduleLookahead: 5, + }, + { + ChainId: common.GoerliLocalnetChain().ChainId, + ConfirmationCount: 2, + ZetaTokenContractAddress: "0xA8D5060feb6B456e886F023709A2795373691E63", + ConnectorContractAddress: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9", + Erc20CustodyContractAddress: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca", + InTxTicker: 2, + OutTxTicker: 2, + WatchUtxoTicker: 0, + GasPriceTicker: 5, + OutboundTxScheduleInterval: 2, + OutboundTxScheduleLookahead: 5, + }, + }, + } +} + +// Validate checks all core params correspond to a chain and there is no duplicate chain id +func (cpl CoreParamsList) Validate() error { + // check all core params correspond to a chain + externalChainMap := make(map[int64]struct{}) + existingChainMap := make(map[int64]struct{}) + + externalChainList := common.ExternalChainList() + for _, chain := range externalChainList { + externalChainMap[chain.ChainId] = struct{}{} + } + + for _, param := range cpl.CoreParams { + if _, ok := externalChainMap[param.ChainId]; !ok { + return fmt.Errorf("chain id %d not found in chain list", param.ChainId) + } + if _, ok := existingChainMap[param.ChainId]; ok { + return fmt.Errorf("duplicated chain id %d found", param.ChainId) + } + existingChainMap[param.ChainId] = struct{}{} + } + return nil +} diff --git a/x/observer/types/core_params_mainnet.go b/x/observer/types/core_params_mainnet.go deleted file mode 100644 index 38ab439aab..0000000000 --- a/x/observer/types/core_params_mainnet.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build !PRIVNET && !TESTNET && !MOCK_MAINNET -// +build !PRIVNET,!TESTNET,!MOCK_MAINNET - -package types - -import ( - "fmt" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/zeta-chain/zetacore/common" -) - -func GetCoreParams() CoreParamsList { - params := CoreParamsList{ - CoreParams: []*CoreParams{ - { - ChainId: common.EthChain().ChainId, - ConfirmationCount: 14, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 12, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BscMainnetChain().ChainId, - ConfirmationCount: 14, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 5, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BtcMainnetChain().ChainId, - ConfirmationCount: 2, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - WatchUtxoTicker: 30, - InTxTicker: 120, - OutTxTicker: 60, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - }, - } - chainList := common.ExternalChainList() - requiredParams := len(chainList) - availableParams := 0 - for _, chain := range chainList { - for _, param := range params.CoreParams { - if chain.ChainId == param.ChainId { - availableParams++ - } - } - } - if availableParams != requiredParams { - panic(fmt.Sprintf("Core params are not available for all chains , DefaultChains : %s , CoreParams : %s", - types.PrettyPrintStruct(chainList), params.String())) - } - return params -} diff --git a/x/observer/types/core_params_mock_mainnet.go b/x/observer/types/core_params_mock_mainnet.go deleted file mode 100644 index 549edc5bf7..0000000000 --- a/x/observer/types/core_params_mock_mainnet.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build MOCK_MAINNET -// +build MOCK_MAINNET - -package types - -import ( - "fmt" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/zeta-chain/zetacore/common" -) - -func GetCoreParams() CoreParamsList { - params := CoreParamsList{ - CoreParams: []*CoreParams{ - { - ChainId: common.EthChain().ChainId, - ConfirmationCount: 6, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 12, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BscMainnetChain().ChainId, - ConfirmationCount: 6, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 5, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BtcMainnetChain().ChainId, - ConfirmationCount: 2, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - WatchUtxoTicker: 30, - InTxTicker: 120, - OutTxTicker: 60, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - }, - } - chainList := common.ExternalChainList() - requiredParams := len(chainList) - availableParams := 0 - for _, chain := range chainList { - for _, param := range params.CoreParams { - if chain.ChainId == param.ChainId { - availableParams++ - } - } - } - if availableParams != requiredParams { - panic(fmt.Sprintf("Core params are not available for all chains , DefaultChains : %s , CoreParams : %s", - types.PrettyPrintStruct(chainList), params.String())) - } - return params -} diff --git a/x/observer/types/core_params_privnet.go b/x/observer/types/core_params_privnet.go deleted file mode 100644 index 832bf57475..0000000000 --- a/x/observer/types/core_params_privnet.go +++ /dev/null @@ -1,58 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package types - -import ( - "fmt" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/zeta-chain/zetacore/common" -) - -func GetCoreParams() CoreParamsList { - params := CoreParamsList{ - CoreParams: []*CoreParams{ - { - ChainId: common.GoerliChain().ChainId, - ConfirmationCount: 2, - ZetaTokenContractAddress: "0xA8D5060feb6B456e886F023709A2795373691E63", - ConnectorContractAddress: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9", - Erc20CustodyContractAddress: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca", - InTxTicker: 2, - OutTxTicker: 2, - WatchUtxoTicker: 0, - GasPriceTicker: 5, - OutboundTxScheduleInterval: 2, - OutboundTxScheduleLookahead: 5, - }, - { - ChainId: common.BtcRegtestChain().ChainId, - ConfirmationCount: 2, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - GasPriceTicker: 5, - WatchUtxoTicker: 1, - InTxTicker: 1, - OutTxTicker: 2, - OutboundTxScheduleInterval: 2, - OutboundTxScheduleLookahead: 5, - }}, - } - chainList := common.ExternalChainList() - requiredParams := len(chainList) - availableParams := 0 - for _, chain := range chainList { - for _, param := range params.CoreParams { - if chain.ChainId == param.ChainId { - availableParams++ - } - } - } - if availableParams != requiredParams { - panic(fmt.Sprintf("Core params are not available for all chains , DefaultChains : %s , CoreParams : %s", - types.PrettyPrintStruct(chainList), params.String())) - } - return params -} diff --git a/x/observer/types/core_params_test.go b/x/observer/types/core_params_test.go new file mode 100644 index 0000000000..273e96d00c --- /dev/null +++ b/x/observer/types/core_params_test.go @@ -0,0 +1,32 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestCoreParamsList_Validate(t *testing.T) { + t.Run("should return no error for default list", func(t *testing.T) { + list := types.GetCoreParams() + err := list.Validate() + require.NoError(t, err) + }) + + t.Run("should return error for invalid chain id", func(t *testing.T) { + list := types.GetCoreParams() + list.CoreParams[0].ChainId = 999 + err := list.Validate() + require.Error(t, err) + require.Contains(t, err.Error(), "not found in chain list") + }) + + t.Run("should return error for duplicated chain ID", func(t *testing.T) { + list := types.GetCoreParams() + list.CoreParams = append(list.CoreParams, list.CoreParams[0]) + err := list.Validate() + require.Error(t, err) + require.Contains(t, err.Error(), "duplicated chain id") + }) +} diff --git a/x/observer/types/core_params_testnet.go b/x/observer/types/core_params_testnet.go deleted file mode 100644 index a2be9be7fc..0000000000 --- a/x/observer/types/core_params_testnet.go +++ /dev/null @@ -1,86 +0,0 @@ -//go:build TESTNET -// +build TESTNET - -package types - -import ( - "fmt" - - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/zeta-chain/zetacore/common" -) - -func GetCoreParams() CoreParamsList { - params := CoreParamsList{ - CoreParams: []*CoreParams{ - { - ChainId: common.GoerliChain().ChainId, - ConfirmationCount: 6, - // This is the actual Zeta token Goerli testnet, we need to specify this address for the integration tests to pass - ZetaTokenContractAddress: "0x0000c304d2934c00db1d51995b9f6996affd17c0", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 12, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BscTestnetChain().ChainId, - ConfirmationCount: 6, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 5, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.MumbaiChain().ChainId, - ConfirmationCount: 12, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - InTxTicker: 2, - OutTxTicker: 15, - WatchUtxoTicker: 0, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 60, - }, - { - ChainId: common.BtcTestNetChain().ChainId, - ConfirmationCount: 2, - ZetaTokenContractAddress: "", - ConnectorContractAddress: "", - Erc20CustodyContractAddress: "", - WatchUtxoTicker: 30, - InTxTicker: 120, - OutTxTicker: 12, - GasPriceTicker: 30, - OutboundTxScheduleInterval: 30, - OutboundTxScheduleLookahead: 100, - }, - }, - } - chainList := common.ExternalChainList() - requiredParams := len(chainList) - availableParams := 0 - for _, chain := range chainList { - for _, param := range params.CoreParams { - if chain.ChainId == param.ChainId { - availableParams++ - } - } - } - if availableParams != requiredParams { - panic(fmt.Sprintf("Core params are not available for all chains , DefaultChains : %s , CoreParams : %s", - types.PrettyPrintStruct(chainList), params.String())) - } - return params -} diff --git a/x/observer/types/errors.go b/x/observer/types/errors.go index c4659faa33..de85c6a161 100644 --- a/x/observer/types/errors.go +++ b/x/observer/types/errors.go @@ -14,7 +14,7 @@ var ( ErrObserverNotPresent = errorsmod.Register(ModuleName, 1105, "observer for type and observation does not exist") ErrNotValidator = errorsmod.Register(ModuleName, 1106, "user needs to be a validator before applying to become an observer") - ErrValidatorStatus = errorsmod.Register(ModuleName, 1107, "corresponding validator needs to be bonded and not jailerd") + ErrValidatorStatus = errorsmod.Register(ModuleName, 1107, "corresponding validator needs to be bonded and not jailed") ErrInvalidAddress = errorsmod.Register(ModuleName, 1108, "invalid Address") ErrSelfDelegation = errorsmod.Register(ModuleName, 1109, "self Delegation for operator not found") ErrCheckObserverDelegation = errorsmod.Register(ModuleName, 1110, "observer delegation not sufficient") @@ -25,10 +25,13 @@ var ( ErrKeygenCompleted = errorsmod.Register(ModuleName, 1115, "keygen already completed") ErrNotAuthorized = errorsmod.Register(ModuleName, 1116, "not authorized") - ErrBlockHeaderNotFound = errorsmod.Register(ModuleName, 1117, "block header not found") - ErrUnrecognizedBlockHeader = errorsmod.Register(ModuleName, 1118, "unrecognized block header") - ErrBlockAlreadyExist = errorsmod.Register(ModuleName, 1119, "block already exists") - ErrNoParentHash = errorsmod.Register(ModuleName, 1120, "no parent hash") - ErrInvalidTimestamp = errorsmod.Register(ModuleName, 1121, "invalid timestamp") - ErrBlockHeaderVerficationDisabled = errorsmod.Register(ModuleName, 1122, "block header verification is disabled") + ErrBlockHeaderNotFound = errorsmod.Register(ModuleName, 1117, "block header not found") + ErrUnrecognizedBlockHeader = errorsmod.Register(ModuleName, 1118, "unrecognized block header") + ErrBlockAlreadyExist = errorsmod.Register(ModuleName, 1119, "block already exists") + ErrNoParentHash = errorsmod.Register(ModuleName, 1120, "no parent hash") + ErrInvalidTimestamp = errorsmod.Register(ModuleName, 1121, "invalid timestamp") + ErrBlockHeaderVerificationDisabled = errorsmod.Register(ModuleName, 1122, "block header verification is disabled") + ErrLastObserverCountNotFound = errorsmod.Register(ModuleName, 1123, "last observer count not found") + ErrUpdateObserver = errorsmod.Register(ModuleName, 1124, "unable to update observer") + ErrNodeAccountNotFound = errorsmod.Register(ModuleName, 1125, "node account not found") ) diff --git a/x/observer/types/expected_keepers.go b/x/observer/types/expected_keepers.go index a2e71f26c0..d6fa8010db 100644 --- a/x/observer/types/expected_keepers.go +++ b/x/observer/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -22,6 +23,12 @@ type StakingKeeper interface { GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + SetValidator(ctx sdk.Context, validator stakingtypes.Validator) +} + +type SlashingKeeper interface { + IsTombstoned(ctx sdk.Context, addr sdk.ConsAddress) bool + SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) } type StakingHooks interface { diff --git a/x/observer/types/genesis.go b/x/observer/types/genesis.go index d43b42e89e..f5b2106b54 100644 --- a/x/observer/types/genesis.go +++ b/x/observer/types/genesis.go @@ -39,6 +39,11 @@ func (gs GenesisState) Validate() error { nodeAccountIndexMap[elem.GetOperator()] = true } + // check for invalid core params + if err := gs.CoreParamsList.Validate(); err != nil { + return err + } + return VerifyObserverMapper(gs.Observers) } diff --git a/x/observer/types/genesis_test.go b/x/observer/types/genesis_test.go index 3bde1d8f5d..91047ccfd1 100644 --- a/x/observer/types/genesis_test.go +++ b/x/observer/types/genesis_test.go @@ -8,6 +8,10 @@ import ( ) func TestGenesisState_Validate(t *testing.T) { + invalidCoreParamsGen := types.DefaultGenesis() + coreParams := types.GetCoreParams().CoreParams + invalidCoreParamsGen.CoreParamsList.CoreParams = append(coreParams, coreParams[0]) + for _, tc := range []struct { desc string genState *types.GenesisState @@ -23,6 +27,11 @@ func TestGenesisState_Validate(t *testing.T) { genState: &types.GenesisState{}, valid: true, }, + { + desc: "invalid core params", + genState: invalidCoreParamsGen, + valid: false, + }, } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() @@ -33,4 +42,7 @@ func TestGenesisState_Validate(t *testing.T) { } }) } + + list := types.GetCoreParams() + list.CoreParams = append(list.CoreParams, list.CoreParams[0]) } diff --git a/x/observer/types/messages_add_block_header.go b/x/observer/types/message_add_block_header.go similarity index 100% rename from x/observer/types/messages_add_block_header.go rename to x/observer/types/message_add_block_header.go diff --git a/x/observer/types/messages_crosschain_flags.go b/x/observer/types/message_crosschain_flags.go similarity index 100% rename from x/observer/types/messages_crosschain_flags.go rename to x/observer/types/message_crosschain_flags.go diff --git a/x/observer/types/messages_crosschain_flags_test.go b/x/observer/types/message_crosschain_flags_test.go similarity index 100% rename from x/observer/types/messages_crosschain_flags_test.go rename to x/observer/types/message_crosschain_flags_test.go diff --git a/x/observer/types/message_update_observer.go b/x/observer/types/message_update_observer.go new file mode 100644 index 0000000000..e5b541859b --- /dev/null +++ b/x/observer/types/message_update_observer.go @@ -0,0 +1,63 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateObserver = "update_observer" + +var _ sdk.Msg = &MsgUpdateObserver{} + +func NewMsgUpdateObserver(creator string, oldObserverAddress string, newObserverAddress string, updateReason ObserverUpdateReason) *MsgUpdateObserver { + return &MsgUpdateObserver{ + Creator: creator, + OldObserverAddress: oldObserverAddress, + NewObserverAddress: newObserverAddress, + UpdateReason: updateReason, + } +} + +func (msg *MsgUpdateObserver) Route() string { + return RouterKey +} + +func (msg *MsgUpdateObserver) Type() string { + return TypeMsgUpdateObserver +} + +func (msg *MsgUpdateObserver) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateObserver) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateObserver) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + _, err = sdk.AccAddressFromBech32(msg.OldObserverAddress) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid old observer address (%s)", err) + } + _, err = sdk.AccAddressFromBech32(msg.NewObserverAddress) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid new observer address (%s)", err) + } + if msg.UpdateReason != ObserverUpdateReason_Tombstoned && msg.UpdateReason != ObserverUpdateReason_AdminUpdate { + return errorsmod.Wrapf(ErrUpdateObserver, "invalid update reason (%s)", msg.UpdateReason) + } + if msg.UpdateReason == ObserverUpdateReason_Tombstoned && msg.OldObserverAddress != msg.Creator { + return errorsmod.Wrapf(ErrUpdateObserver, "invalid old observer address (%s)", msg.OldObserverAddress) + } + return nil +} diff --git a/x/observer/types/message_update_observer_test.go b/x/observer/types/message_update_observer_test.go new file mode 100644 index 0000000000..0cff6bd25b --- /dev/null +++ b/x/observer/types/message_update_observer_test.go @@ -0,0 +1,88 @@ +package types_test + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestNewMsgUpdateObserver(t *testing.T) { + tests := []struct { + name string + msg types.MsgUpdateObserver + err error + }{ + { + name: "invalid creator", + msg: types.MsgUpdateObserver{ + Creator: "invalid_address", + OldObserverAddress: sample.AccAddress(), + NewObserverAddress: sample.AccAddress(), + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid old observer address", + msg: types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: "invalid_address", + NewObserverAddress: sample.AccAddress(), + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid new observer address", + msg: types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: sample.AccAddress(), + NewObserverAddress: "invalid_address", + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "old observer address is not creator", + msg: types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: sample.AccAddress(), + NewObserverAddress: sample.AccAddress(), + UpdateReason: types.ObserverUpdateReason_Tombstoned, + }, + err: types.ErrUpdateObserver, + }, + { + name: "invalid Update Reason", + msg: types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: sample.AccAddress(), + NewObserverAddress: sample.AccAddress(), + UpdateReason: types.ObserverUpdateReason(100), + }, + err: types.ErrUpdateObserver, + }, + { + name: "valid message", + msg: types.MsgUpdateObserver{ + Creator: sample.AccAddress(), + OldObserverAddress: sample.AccAddress(), + NewObserverAddress: sample.AccAddress(), + UpdateReason: types.ObserverUpdateReason_AdminUpdate, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/observer/types/observer.pb.go b/x/observer/types/observer.pb.go index 6fec7d7b3d..6276da7570 100644 --- a/x/observer/types/observer.pb.go +++ b/x/observer/types/observer.pb.go @@ -59,6 +59,34 @@ func (ObservationType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_3004233a4a5969ce, []int{0} } +type ObserverUpdateReason int32 + +const ( + ObserverUpdateReason_Undefined ObserverUpdateReason = 0 + ObserverUpdateReason_Tombstoned ObserverUpdateReason = 1 + ObserverUpdateReason_AdminUpdate ObserverUpdateReason = 2 +) + +var ObserverUpdateReason_name = map[int32]string{ + 0: "Undefined", + 1: "Tombstoned", + 2: "AdminUpdate", +} + +var ObserverUpdateReason_value = map[string]int32{ + "Undefined": 0, + "Tombstoned": 1, + "AdminUpdate": 2, +} + +func (x ObserverUpdateReason) String() string { + return proto.EnumName(ObserverUpdateReason_name, int32(x)) +} + +func (ObserverUpdateReason) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_3004233a4a5969ce, []int{1} +} + type ObserverMapper struct { Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` ObserverChain *common.Chain `protobuf:"bytes,2,opt,name=observer_chain,json=observerChain,proto3" json:"observer_chain,omitempty"` @@ -173,6 +201,7 @@ func (m *LastObserverCount) GetLastChangeHeight() int64 { func init() { proto.RegisterEnum("zetachain.zetacore.observer.ObservationType", ObservationType_name, ObservationType_value) + proto.RegisterEnum("zetachain.zetacore.observer.ObserverUpdateReason", ObserverUpdateReason_name, ObserverUpdateReason_value) proto.RegisterType((*ObserverMapper)(nil), "zetachain.zetacore.observer.ObserverMapper") proto.RegisterType((*LastObserverCount)(nil), "zetachain.zetacore.observer.LastObserverCount") } @@ -180,30 +209,33 @@ func init() { func init() { proto.RegisterFile("observer/observer.proto", fileDescriptor_3004233a4a5969ce) } var fileDescriptor_3004233a4a5969ce = []byte{ - // 367 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x51, 0xcf, 0x6a, 0x22, 0x31, - 0x1c, 0x9e, 0xe8, 0xec, 0x82, 0xd9, 0xd5, 0x1d, 0xb3, 0x96, 0x8a, 0x85, 0x20, 0xf6, 0x22, 0xa5, - 0x9d, 0x40, 0xdb, 0x27, 0x50, 0x4a, 0x2b, 0xb5, 0x08, 0xa3, 0x50, 0xe8, 0x45, 0x46, 0x0d, 0x33, - 0x01, 0x4d, 0x86, 0x99, 0x4c, 0x71, 0x7a, 0xeb, 0x1b, 0xf4, 0x21, 0x7a, 0xe8, 0xa3, 0xf4, 0xe8, - 0xb1, 0xc7, 0xa2, 0x2f, 0x52, 0x92, 0x18, 0x4f, 0xf9, 0xfe, 0x24, 0xf9, 0x7d, 0x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87, 0x29, 0xd1, 0x73, 0x50, 0x15, 0x56, 0x06, 0xbc, 0x27, 0x72, 0xbe, 0x98, - 0xac, 0x3d, 0x80, 0x6a, 0x10, 0x8e, 0x72, 0x69, 0x79, 0x49, 0xd9, 0x93, 0xf1, 0xf8, 0x9e, 0x16, - 0xb7, 0x94, 0x7b, 0x65, 0x65, 0x1b, 0x3a, 0x66, 0x11, 0xf7, 0xdc, 0x96, 0xfb, 0xf1, 0x8e, 0x41, - 0x6f, 0xf0, 0xb9, 0xc5, 0x60, 0xb3, 0xc5, 0xe0, 0x7b, 0x8b, 0xc1, 0xdb, 0x0e, 0x3b, 0x9b, 0x1d, - 0x76, 0xbe, 0x76, 0xd8, 0x79, 0x22, 0x11, 0x93, 0x71, 0x3e, 0x53, 0x9b, 0x22, 0xaa, 0xad, 0x0b, - 0xbd, 0x40, 0x62, 0x8b, 0x23, 0xeb, 0x43, 0xbb, 0x44, 0x16, 0x09, 0xcd, 0x66, 0xbf, 0x75, 0x39, - 0x57, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xad, 0xb9, 0x91, 0xff, 0x01, 0x00, 0x00, + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x52, 0xd1, 0x8a, 0xd3, 0x40, + 0x14, 0xcd, 0xb4, 0x51, 0xe8, 0xac, 0xed, 0x66, 0xc7, 0x8a, 0xa5, 0x42, 0x28, 0xeb, 0x4b, 0x59, + 0x34, 0x03, 0xea, 0x0f, 0xb8, 0x45, 0x74, 0xb1, 0xb2, 0x90, 0x76, 0x11, 0x7c, 0x29, 0x93, 0xe6, + 0x9a, 0x0c, 0x34, 0x33, 0x21, 0x33, 0x91, 0xc6, 0x37, 0xff, 0xc0, 0x8f, 0xf0, 0xc1, 0x4f, 0xf1, + 0x71, 0x1f, 0x7d, 0x94, 0xf6, 0x47, 0x64, 0x66, 0x76, 0xf6, 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xc1, + 0x67, 0xef, 0xaa, 0x5a, 0x77, 0x7e, 0x98, 0x11, 0xa3, 0x80, 0x0c, 0xf1, 0xe0, 0x4a, 0x5c, 0xca, + 0x56, 0xe4, 0xeb, 0x7d, 0x84, 0xc8, 0x08, 0xe3, 0xeb, 0x56, 0x7b, 0xde, 0x33, 0xe5, 0xf5, 0x6a, + 0xf5, 0x11, 0xba, 0xf7, 0x20, 0xa2, 0xbe, 0x29, 0x3b, 0xba, 0xe2, 0x85, 0x88, 0xc2, 0x69, 0xf8, + 0xfb, 0x57, 0x8c, 0x2e, 0x96, 0x78, 0xec, 0xbb, 0xde, 0xd4, 0x39, 0xd3, 0x90, 0x02, 0x53, 0x52, + 0x18, 0xf3, 0x8d, 0xc8, 0xe1, 0x2b, 0x17, 0x90, 0x47, 0x81, 0x35, 0xcb, 0x2a, 0x53, 0x5a, 0x1a, + 0x8e, 0xc8, 0x29, 0x3e, 0x79, 0x9b, 0x57, 0x5c, 0x38, 0x4f, 0xd4, 0x73, 0xdd, 0x2e, 0xaf, 0xfe, + 0x1c, 0x62, 0x74, 0x7b, 0x88, 0xd1, 0xbf, 0x43, 0x8c, 0x7e, 0x1e, 0xe3, 0xe0, 0xf6, 0x18, 0x07, + 0x7f, 0x8f, 0x71, 0xf0, 0x85, 0x16, 0x5c, 0x97, 0x6d, 0x66, 0xfe, 0x3b, 0x35, 0xbb, 0x7f, 0x69, + 0xd7, 0x41, 0xfd, 0x19, 0xd0, 0xfd, 0xfd, 0xad, 0x50, 0xdd, 0xd5, 0xa0, 0xb2, 0x87, 0x76, 0xd5, + 0xaf, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x0c, 0x23, 0x95, 0x4d, 0x02, 0x00, 0x00, } func (m *ObserverMapper) Marshal() (dAtA []byte, err error) { diff --git a/x/observer/types/params.go b/x/observer/types/params.go index bff524b297..9b755af3cf 100644 --- a/x/observer/types/params.go +++ b/x/observer/types/params.go @@ -17,11 +17,18 @@ func ParamKeyTable() paramtypes.KeyTable { } func NewParams(observerParams []*ObserverParams, adminParams []*Admin_Policy, ballotMaturityBlocks int64) Params { - return Params{ObserverParams: observerParams, AdminPolicy: adminParams, BallotMaturityBlocks: ballotMaturityBlocks} + return Params{ + ObserverParams: observerParams, + AdminPolicy: adminParams, + BallotMaturityBlocks: ballotMaturityBlocks, + } } +// DefaultParams returns a default set of parameters. +// privnet chains are supported by default for testing purposes +// custom params must be provided in genesis for other networks func DefaultParams() Params { - chains := common.DefaultChainsList() + chains := common.PrivnetChainList() observerParams := make([]*ObserverParams, len(chains)) for i, chain := range chains { observerParams[i] = &ObserverParams{ @@ -135,7 +142,8 @@ func (p Params) GetSupportedChains() (chains []*common.Chain) { } func (p Params) GetChainFromChainID(chainID int64) *common.Chain { - for _, observerParam := range p.GetObserverParams() { + chainList := p.GetObserverParams() + for _, observerParam := range chainList { if observerParam.Chain.ChainId == chainID && observerParam.IsSupported { return observerParam.Chain } diff --git a/x/observer/types/test_data.go b/x/observer/types/test_data.go index 611e9a0127..bac2ae27a5 100644 --- a/x/observer/types/test_data.go +++ b/x/observer/types/test_data.go @@ -8,6 +8,8 @@ import ( "github.com/zeta-chain/zetacore/common" ) +const PrefixOutput = "Output1" + func CreateObserverMapperList(items int, chain common.Chain) (list []*ObserverMapper) { SetConfig(false) for i := 0; i < items; i++ { @@ -15,10 +17,10 @@ func CreateObserverMapperList(items int, chain common.Chain) (list []*ObserverMa Index: "Index" + strconv.Itoa(i), ObserverChain: &chain, ObserverList: []string{ - sdk.AccAddress(crypto.AddressHash([]byte("Output1" + strconv.Itoa(i)))).String(), - sdk.AccAddress(crypto.AddressHash([]byte("Output1" + strconv.Itoa(i+1)))).String(), - sdk.AccAddress(crypto.AddressHash([]byte("Output1" + strconv.Itoa(i+2)))).String(), - sdk.AccAddress(crypto.AddressHash([]byte("Output1" + strconv.Itoa(i+3)))).String(), + sdk.AccAddress(crypto.AddressHash([]byte(PrefixOutput + strconv.Itoa(i)))).String(), + sdk.AccAddress(crypto.AddressHash([]byte(PrefixOutput + strconv.Itoa(i+1)))).String(), + sdk.AccAddress(crypto.AddressHash([]byte(PrefixOutput + strconv.Itoa(i+2)))).String(), + sdk.AccAddress(crypto.AddressHash([]byte(PrefixOutput + strconv.Itoa(i+3)))).String(), }, } list = append(list, mapper) diff --git a/x/observer/types/tx.pb.go b/x/observer/types/tx.pb.go index 567b27d987..47f67f97da 100644 --- a/x/observer/types/tx.pb.go +++ b/x/observer/types/tx.pb.go @@ -30,6 +30,110 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgUpdateObserver struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + OldObserverAddress string `protobuf:"bytes,2,opt,name=old_observer_address,json=oldObserverAddress,proto3" json:"old_observer_address,omitempty"` + NewObserverAddress string `protobuf:"bytes,3,opt,name=new_observer_address,json=newObserverAddress,proto3" json:"new_observer_address,omitempty"` + UpdateReason ObserverUpdateReason `protobuf:"varint,4,opt,name=update_reason,json=updateReason,proto3,enum=zetachain.zetacore.observer.ObserverUpdateReason" json:"update_reason,omitempty"` +} + +func (m *MsgUpdateObserver) Reset() { *m = MsgUpdateObserver{} } +func (m *MsgUpdateObserver) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateObserver) ProtoMessage() {} +func (*MsgUpdateObserver) Descriptor() ([]byte, []int) { + return fileDescriptor_1bcd40fa296a2b1d, []int{0} +} +func (m *MsgUpdateObserver) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateObserver) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateObserver.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateObserver) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateObserver.Merge(m, src) +} +func (m *MsgUpdateObserver) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateObserver) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateObserver.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateObserver proto.InternalMessageInfo + +func (m *MsgUpdateObserver) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateObserver) GetOldObserverAddress() string { + if m != nil { + return m.OldObserverAddress + } + return "" +} + +func (m *MsgUpdateObserver) GetNewObserverAddress() string { + if m != nil { + return m.NewObserverAddress + } + return "" +} + +func (m *MsgUpdateObserver) GetUpdateReason() ObserverUpdateReason { + if m != nil { + return m.UpdateReason + } + return ObserverUpdateReason_Undefined +} + +type MsgUpdateObserverResponse struct { +} + +func (m *MsgUpdateObserverResponse) Reset() { *m = MsgUpdateObserverResponse{} } +func (m *MsgUpdateObserverResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateObserverResponse) ProtoMessage() {} +func (*MsgUpdateObserverResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1bcd40fa296a2b1d, []int{1} +} +func (m *MsgUpdateObserverResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateObserverResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateObserverResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateObserverResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateObserverResponse.Merge(m, src) +} +func (m *MsgUpdateObserverResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateObserverResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateObserverResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateObserverResponse proto.InternalMessageInfo + type MsgAddBlockHeader struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -42,7 +146,7 @@ func (m *MsgAddBlockHeader) Reset() { *m = MsgAddBlockHeader{} } func (m *MsgAddBlockHeader) String() string { return proto.CompactTextString(m) } func (*MsgAddBlockHeader) ProtoMessage() {} func (*MsgAddBlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{0} + return fileDescriptor_1bcd40fa296a2b1d, []int{2} } func (m *MsgAddBlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,7 +217,7 @@ func (m *MsgAddBlockHeaderResponse) Reset() { *m = MsgAddBlockHeaderResp func (m *MsgAddBlockHeaderResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddBlockHeaderResponse) ProtoMessage() {} func (*MsgAddBlockHeaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{1} + return fileDescriptor_1bcd40fa296a2b1d, []int{3} } func (m *MsgAddBlockHeaderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -151,7 +255,7 @@ func (m *MsgUpdateCoreParams) Reset() { *m = MsgUpdateCoreParams{} } func (m *MsgUpdateCoreParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCoreParams) ProtoMessage() {} func (*MsgUpdateCoreParams) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{2} + return fileDescriptor_1bcd40fa296a2b1d, []int{4} } func (m *MsgUpdateCoreParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -201,7 +305,7 @@ func (m *MsgUpdateCoreParamsResponse) Reset() { *m = MsgUpdateCoreParams func (m *MsgUpdateCoreParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCoreParamsResponse) ProtoMessage() {} func (*MsgUpdateCoreParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{3} + return fileDescriptor_1bcd40fa296a2b1d, []int{5} } func (m *MsgUpdateCoreParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -241,7 +345,7 @@ func (m *MsgAddObserver) Reset() { *m = MsgAddObserver{} } func (m *MsgAddObserver) String() string { return proto.CompactTextString(m) } func (*MsgAddObserver) ProtoMessage() {} func (*MsgAddObserver) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{4} + return fileDescriptor_1bcd40fa296a2b1d, []int{6} } func (m *MsgAddObserver) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +409,7 @@ func (m *MsgAddObserverResponse) Reset() { *m = MsgAddObserverResponse{} func (m *MsgAddObserverResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddObserverResponse) ProtoMessage() {} func (*MsgAddObserverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{5} + return fileDescriptor_1bcd40fa296a2b1d, []int{7} } func (m *MsgAddObserverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -344,7 +448,7 @@ func (m *MsgAddBlameVote) Reset() { *m = MsgAddBlameVote{} } func (m *MsgAddBlameVote) String() string { return proto.CompactTextString(m) } func (*MsgAddBlameVote) ProtoMessage() {} func (*MsgAddBlameVote) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{6} + return fileDescriptor_1bcd40fa296a2b1d, []int{8} } func (m *MsgAddBlameVote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -401,7 +505,7 @@ func (m *MsgAddBlameVoteResponse) Reset() { *m = MsgAddBlameVoteResponse func (m *MsgAddBlameVoteResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddBlameVoteResponse) ProtoMessage() {} func (*MsgAddBlameVoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{7} + return fileDescriptor_1bcd40fa296a2b1d, []int{9} } func (m *MsgAddBlameVoteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -442,7 +546,7 @@ func (m *MsgUpdateCrosschainFlags) Reset() { *m = MsgUpdateCrosschainFla func (m *MsgUpdateCrosschainFlags) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCrosschainFlags) ProtoMessage() {} func (*MsgUpdateCrosschainFlags) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{8} + return fileDescriptor_1bcd40fa296a2b1d, []int{10} } func (m *MsgUpdateCrosschainFlags) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -513,7 +617,7 @@ func (m *MsgUpdateCrosschainFlagsResponse) Reset() { *m = MsgUpdateCross func (m *MsgUpdateCrosschainFlagsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCrosschainFlagsResponse) ProtoMessage() {} func (*MsgUpdateCrosschainFlagsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{9} + return fileDescriptor_1bcd40fa296a2b1d, []int{11} } func (m *MsgUpdateCrosschainFlagsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -551,7 +655,7 @@ func (m *MsgUpdateKeygen) Reset() { *m = MsgUpdateKeygen{} } func (m *MsgUpdateKeygen) String() string { return proto.CompactTextString(m) } func (*MsgUpdateKeygen) ProtoMessage() {} func (*MsgUpdateKeygen) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{10} + return fileDescriptor_1bcd40fa296a2b1d, []int{12} } func (m *MsgUpdateKeygen) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -601,7 +705,7 @@ func (m *MsgUpdateKeygenResponse) Reset() { *m = MsgUpdateKeygenResponse func (m *MsgUpdateKeygenResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateKeygenResponse) ProtoMessage() {} func (*MsgUpdateKeygenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1bcd40fa296a2b1d, []int{11} + return fileDescriptor_1bcd40fa296a2b1d, []int{13} } func (m *MsgUpdateKeygenResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -631,6 +735,8 @@ func (m *MsgUpdateKeygenResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateKeygenResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgUpdateObserver)(nil), "zetachain.zetacore.observer.MsgUpdateObserver") + proto.RegisterType((*MsgUpdateObserverResponse)(nil), "zetachain.zetacore.observer.MsgUpdateObserverResponse") proto.RegisterType((*MsgAddBlockHeader)(nil), "zetachain.zetacore.observer.MsgAddBlockHeader") proto.RegisterType((*MsgAddBlockHeaderResponse)(nil), "zetachain.zetacore.observer.MsgAddBlockHeaderResponse") proto.RegisterType((*MsgUpdateCoreParams)(nil), "zetachain.zetacore.observer.MsgUpdateCoreParams") @@ -648,58 +754,63 @@ func init() { func init() { proto.RegisterFile("observer/tx.proto", fileDescriptor_1bcd40fa296a2b1d) } var fileDescriptor_1bcd40fa296a2b1d = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4b, 0x4f, 0xeb, 0x46, - 0x14, 0x8e, 0x2f, 0x17, 0x2e, 0x39, 0x41, 0x3c, 0x06, 0x02, 0x4e, 0x28, 0x21, 0xf2, 0xa6, 0x69, - 0x4b, 0x63, 0x1a, 0xda, 0xaa, 0xad, 0xd4, 0x45, 0xe8, 0x03, 0xa2, 0x8a, 0x82, 0x2c, 0x95, 0x45, - 0x37, 0xd6, 0xd8, 0x33, 0xb1, 0x2d, 0x92, 0x99, 0xc8, 0xe3, 0x54, 0x49, 0xa5, 0x76, 0xdf, 0x45, - 0xa5, 0xfe, 0x95, 0xfe, 0x87, 0x2e, 0x58, 0xb2, 0xec, 0xaa, 0xaa, 0x60, 0xd3, 0x7f, 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, 0xdf, 0xd0, 0x71, 0x68, 0x0f, 0x55, 0xd5, 0xe5, 0xaa, 0x52, 0x2b, - 0x34, 0x50, 0x3d, 0xae, 0x4e, 0x14, 0xcb, 0xd7, 0x38, 0xc0, 0xa7, 0xaf, 0x6f, 0xff, 0x39, 0xcc, - 0x19, 0x31, 0x4e, 0xdb, 0x87, 0xd2, 0x54, 0xc8, 0x06, 0x15, 0x3d, 0xce, 0x04, 0xd5, 0x06, 0xb0, - 0x7d, 0x21, 0x9c, 0x1f, 0x7a, 0x04, 0x07, 0xf4, 0x2b, 0xee, 0xd3, 0x2b, 0x99, 0x6d, 0x46, 0x46, - 0x67, 0x00, 0x76, 0x8a, 0x93, 0x39, 0x15, 0x1a, 0xef, 0xd6, 0x33, 0xba, 0x58, 0x1f, 0xd1, 0x1a, - 0x63, 0xae, 0xda, 0x01, 0xec, 0xcf, 0x50, 0x4e, 0x03, 0xfb, 0x4b, 0x81, 0xf5, 0x28, 0xec, 0xcb, - 0x98, 0x28, 0x23, 0xa8, 0xf7, 0x60, 0x33, 0x91, 0x33, 0x31, 0x21, 0x3e, 0x15, 0x51, 0x68, 0x79, - 0x63, 0x23, 0xb1, 0x37, 0x23, 0x33, 0xfa, 0x02, 0x4a, 0x32, 0xc4, 0x8e, 0x47, 0x59, 0x60, 0x3a, - 0x3e, 0x66, 0x01, 0xa5, 0x66, 0xaf, 0x6f, 0xdd, 0xd0, 0xa1, 0xec, 0x42, 0xde, 0xd8, 0x1b, 0x01, - 0xce, 0xa2, 0xf7, 0x2b, 0xf9, 0x8c, 0x3e, 0x82, 0x22, 0x26, 0xc4, 0x64, 0x9c, 0x50, 0x13, 0xdb, - 0x36, 0xef, 0xb3, 0xc0, 0xe4, 0xac, 0x33, 0x94, 0x2d, 0x5a, 0x35, 0x10, 0x26, 0xe4, 0x7b, 0x4e, - 0x68, 0x33, 0x7a, 0xba, 0x64, 0x9d, 0xa1, 0xa6, 0xc2, 0xee, 0x64, 0x16, 0x69, 0x82, 0x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x84, 0xbd, 0xf1, 0xdf, 0x32, 0x2c, 0x5d, 0x08, 0x07, 0x71, 0x28, 0x8c, 0xef, 0xe1, - 0x07, 0x99, 0x19, 0x4f, 0x8e, 0x7b, 0xf9, 0x64, 0x01, 0x70, 0x22, 0x8c, 0x7e, 0x85, 0xcd, 0xa9, - 0x7f, 0x49, 0xc7, 0xcf, 0x11, 0x3d, 0xf6, 0x28, 0x7f, 0xb6, 0xa8, 0x47, 0xaa, 0xef, 0xc3, 0xda, - 0xc4, 0x5e, 0x1e, 0xcd, 0x91, 0x44, 0x8a, 0x2e, 0x7f, 0xbc, 0x08, 0x3a, 0xd5, 0xfc, 0x5d, 0x81, - 0xe2, 0xec, 0x2d, 0xfb, 0x64, 0xce, 0x3c, 0x26, 0xdd, 0xca, 0x5f, 0xbe, 0xc8, 0x6d, 0xbc, 0x06, - 0x13, 0x73, 0x75, 0x34, 0x1f, 0x5d, 0x84, 0x7e, 0xbe, 0x06, 0xb3, 0x06, 0x0e, 0x0d, 0x60, 0xfd, - 0xd1, 0x4f, 0x6b, 0x7d, 0xae, 0x5a, 0xa6, 0xf8, 0xf2, 0xa7, 0x8b, 0xe1, 0x13, 0xe5, 0xd3, 0xd6, - 0xed, 0x7d, 0x45, 0xb9, 0xbb, 0xaf, 0x28, 0xff, 0xde, 0x57, 0x94, 0x3f, 0x1e, 0x2a, 0xb9, 0xbb, - 0x87, 0x4a, 0xee, 0xef, 0x87, 0x4a, 0xee, 0x47, 0xdd, 0xf1, 0x02, 0xb7, 0x6f, 0x85, 0x3f, 0xb3, - 0x7a, 0xc8, 0xf8, 0xa1, 0x24, 0xd7, 0x13, 0x72, 0x7d, 0xa0, 0x8f, 0xbe, 0x6a, 0x86, 0x3d, 0x2a, - 0xac, 0x15, 0xf9, 0xa9, 0x70, 0xf2, 0x36, 0x00, 0x00, 0xff, 0xff, 0x46, 0x18, 0xe1, 0x9b, 0xee, - 0x08, 0x00, 0x00, + // 886 bytes of a gzipped FileDescriptorProto + 0x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0xfd, 0xd3, 0xf9, 0xf0, 0x3a, 0xf3, + 0xaf, 0xb0, 0x3e, 0xf1, 0x31, 0x3c, 0x9c, 0x8d, 0x6b, 0x18, 0x51, 0xff, 0x6c, 0xde, 0x08, 0x9d, + 0x3f, 0x81, 0xd5, 0xd2, 0x17, 0xe1, 0x60, 0x86, 0xf6, 0x69, 0x74, 0xfd, 0xe3, 0x79, 0xd0, 0x3a, + 0xe7, 0xef, 0x06, 0x6c, 0x4d, 0x7f, 0xbf, 0x3f, 0x99, 0x51, 0x47, 0x39, 0xac, 0xfe, 0xe5, 0x5b, + 0x85, 0x8d, 0xf6, 0xa0, 0xe4, 0xe8, 0x83, 0xd9, 0xe8, 0x14, 0xfa, 0xe6, 0x1e, 0x4c, 0xb3, 0x7a, + 0xe6, 0xb8, 0xb1, 0x4b, 0xbd, 0x39, 0x53, 0x2f, 0x35, 0xfe, 0x66, 0xc7, 0x4d, 0xbf, 0x81, 0x8f, + 0x3a, 0xaf, 0x2e, 0x1b, 0xc6, 0xeb, 0xcb, 0x86, 0xf1, 0xef, 0x65, 0xc3, 0xf8, 0xe3, 0xaa, 0xb1, + 0xf0, 0xfa, 0xaa, 0xb1, 0xf0, 0xf7, 0x55, 0x63, 0xe1, 0x47, 0x3b, 0x88, 0xd2, 0xb0, 0xef, 0x65, + 0x17, 0xbc, 0x9d, 0x31, 0x7e, 0x24, 0xc9, 0xed, 0x82, 0xdc, 0xbe, 0xb0, 0x87, 0x7f, 0x2c, 0x07, + 0x3d, 0x14, 0xde, 0x92, 0xfc, 0xb7, 0xf6, 0xf4, 0x4d, 0x00, 0x00, 0x00, 0xff, 0xff, 0x26, 0x4e, + 0x23, 0xa3, 0x71, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -715,6 +826,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { AddObserver(ctx context.Context, in *MsgAddObserver, opts ...grpc.CallOption) (*MsgAddObserverResponse, error) + UpdateObserver(ctx context.Context, in *MsgUpdateObserver, opts ...grpc.CallOption) (*MsgUpdateObserverResponse, error) UpdateCoreParams(ctx context.Context, in *MsgUpdateCoreParams, opts ...grpc.CallOption) (*MsgUpdateCoreParamsResponse, error) AddBlameVote(ctx context.Context, in *MsgAddBlameVote, opts ...grpc.CallOption) (*MsgAddBlameVoteResponse, error) UpdateCrosschainFlags(ctx context.Context, in *MsgUpdateCrosschainFlags, opts ...grpc.CallOption) (*MsgUpdateCrosschainFlagsResponse, error) @@ -739,6 +851,15 @@ func (c *msgClient) AddObserver(ctx context.Context, in *MsgAddObserver, opts .. return out, nil } +func (c *msgClient) UpdateObserver(ctx context.Context, in *MsgUpdateObserver, opts ...grpc.CallOption) (*MsgUpdateObserverResponse, error) { + out := new(MsgUpdateObserverResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Msg/UpdateObserver", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateCoreParams(ctx context.Context, in *MsgUpdateCoreParams, opts ...grpc.CallOption) (*MsgUpdateCoreParamsResponse, error) { out := new(MsgUpdateCoreParamsResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Msg/UpdateCoreParams", in, out, opts...) @@ -787,6 +908,7 @@ func (c *msgClient) AddBlockHeader(ctx context.Context, in *MsgAddBlockHeader, o // MsgServer is the server API for Msg service. type MsgServer interface { AddObserver(context.Context, *MsgAddObserver) (*MsgAddObserverResponse, error) + UpdateObserver(context.Context, *MsgUpdateObserver) (*MsgUpdateObserverResponse, error) UpdateCoreParams(context.Context, *MsgUpdateCoreParams) (*MsgUpdateCoreParamsResponse, error) AddBlameVote(context.Context, *MsgAddBlameVote) (*MsgAddBlameVoteResponse, error) UpdateCrosschainFlags(context.Context, *MsgUpdateCrosschainFlags) (*MsgUpdateCrosschainFlagsResponse, error) @@ -801,6 +923,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) AddObserver(ctx context.Context, req *MsgAddObserver) (*MsgAddObserverResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddObserver not implemented") } +func (*UnimplementedMsgServer) UpdateObserver(ctx context.Context, req *MsgUpdateObserver) (*MsgUpdateObserverResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateObserver not implemented") +} func (*UnimplementedMsgServer) UpdateCoreParams(ctx context.Context, req *MsgUpdateCoreParams) (*MsgUpdateCoreParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateCoreParams not implemented") } @@ -839,6 +964,24 @@ func _Msg_AddObserver_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Msg_UpdateObserver_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateObserver) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateObserver(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.observer.Msg/UpdateObserver", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateObserver(ctx, req.(*MsgUpdateObserver)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_UpdateCoreParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateCoreParams) if err := dec(in); err != nil { @@ -937,6 +1080,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AddObserver", Handler: _Msg_AddObserver_Handler, }, + { + MethodName: "UpdateObserver", + Handler: _Msg_UpdateObserver_Handler, + }, { MethodName: "UpdateCoreParams", Handler: _Msg_UpdateCoreParams_Handler, @@ -962,6 +1109,78 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "observer/tx.proto", } +func (m *MsgUpdateObserver) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateObserver) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateObserver) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UpdateReason != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.UpdateReason)) + i-- + dAtA[i] = 0x20 + } + if len(m.NewObserverAddress) > 0 { + i -= len(m.NewObserverAddress) + copy(dAtA[i:], m.NewObserverAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewObserverAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.OldObserverAddress) > 0 { + i -= len(m.OldObserverAddress) + copy(dAtA[i:], m.OldObserverAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.OldObserverAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateObserverResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateObserverResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateObserverResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgAddBlockHeader) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1420,6 +1639,39 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgUpdateObserver) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.OldObserverAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewObserverAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.UpdateReason != 0 { + n += 1 + sovTx(uint64(m.UpdateReason)) + } + return n +} + +func (m *MsgUpdateObserverResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgAddBlockHeader) Size() (n int) { if m == nil { return 0 @@ -1609,6 +1861,221 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgUpdateObserver) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateObserver: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateObserver: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldObserverAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OldObserverAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewObserverAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewObserverAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateReason", wireType) + } + m.UpdateReason = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UpdateReason |= ObserverUpdateReason(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateObserverResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateObserverResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateObserverResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgAddBlockHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index 200e985405..62a3683761 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -75,7 +75,6 @@ const ( minConfirmations = 0 maxHeightDiff = 10000 btcBlocksPerDay = 144 - bytesPerKB = 1000 ) func (ob *BitcoinChainClient) WithZetaClient(bridge *ZetaCoreBridge) { @@ -265,7 +264,12 @@ func (ob *BitcoinChainClient) GetBaseGasPrice() *big.Int { } func (ob *BitcoinChainClient) WatchInTx() { - ticker := NewDynamicTicker("Bitcoin_WatchInTx", ob.GetCoreParams().InTxTicker) + ticker, err := NewDynamicTicker("Bitcoin_WatchInTx", ob.GetCoreParams().InTxTicker) + if err != nil { + ob.logger.WatchInTx.Error().Err(err).Msg("WatchInTx error") + return + } + defer ticker.Stop() for { select { @@ -317,7 +321,6 @@ func (ob *BitcoinChainClient) postBlockHeader(tip int64) error { return err } -// TODO func (ob *BitcoinChainClient) observeInTx() error { cnt, err := ob.rpcClient.GetBlockCount() if err != nil { @@ -374,7 +377,13 @@ func (ob *BitcoinChainClient) observeInTx() error { tssAddress := ob.Tss.BTCAddress() // #nosec G701 always positive - inTxs := FilterAndParseIncomingTx(res.Block.Tx, uint64(res.Block.Height), tssAddress, &ob.logger.WatchInTx) + inTxs := FilterAndParseIncomingTx( + res.Block.Tx, + uint64(res.Block.Height), + tssAddress, + &ob.logger.WatchInTx, + ob.chain.ChainId, + ) for _, inTx := range inTxs { msg := ob.GetInboundVoteMessageFromBtcEvent(inTx) @@ -415,21 +424,7 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64 ob.Mu.Unlock() // Get original cctx parameters - params, err := ob.GetPendingCctxParams(nonce) - if err != nil { - ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce) - return false, false, err - } - - // Get original cctx parameters - params, err = ob.GetPendingCctxParams(nonce) - if err != nil { - ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce) - return false, false, err - } - - // Get original cctx parameters - params, err = ob.GetPendingCctxParams(nonce) + params, err := ob.GetCctxParams(nonce) if err != nil { ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce) return false, false, err @@ -491,15 +486,20 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64 common.CoinType_Gas, ) if err != nil { - logger.Error().Err(err).Msgf("error posting to zeta core") + logger.Error().Err(err).Msgf("IsSendOutTxProcessed: error confirming bitcoin outTx %s outTxID %s", res.TxID, outTxID) } else { - logger.Info().Msgf("Bitcoin outTx %s confirmed: PostReceiveConfirmation zeta tx: %s", res.TxID, zetaHash) + logger.Info().Msgf("IsSendOutTxProcessed: confirmed bitcoin outTx %s outTxID %s, zeta tx hash %s", res.TxID, outTxID, zetaHash) } return true, true, nil } func (ob *BitcoinChainClient) WatchGasPrice() { - ticker := NewDynamicTicker("Bitcoin_WatchGasPrice", ob.GetCoreParams().GasPriceTicker) + ticker, err := NewDynamicTicker("Bitcoin_WatchGasPrice", ob.GetCoreParams().GasPriceTicker) + if err != nil { + ob.logger.WatchGasPrice.Error().Err(err).Msg("WatchGasPrice error") + return + } + defer ticker.Stop() for { select { @@ -543,9 +543,7 @@ func (ob *BitcoinChainClient) PostGasPrice() error { if *feeResult.FeeRate > math.MaxInt64 { return fmt.Errorf("gas price is too large: %f", *feeResult.FeeRate) } - // #nosec G701 always in range - feeRate := new(big.Int).SetInt64(int64(*feeResult.FeeRate * 1e8)) - feeRatePerByte := new(big.Int).Div(feeRate, big.NewInt(bytesPerKB)) + feeRatePerByte := feeRateToSatPerByte(*feeResult.FeeRate) bn, err := ob.rpcClient.GetBlockCount() if err != nil { return err @@ -573,13 +571,19 @@ type BTCInTxEvnet struct { // relevant tx must have the following vouts as the first two vouts: // vout0: p2wpkh to the TSS address (targetAddress) // vout1: OP_RETURN memo, base64 encoded -func FilterAndParseIncomingTx(txs []btcjson.TxRawResult, blockNumber uint64, targetAddress string, logger *zerolog.Logger) []*BTCInTxEvnet { +func FilterAndParseIncomingTx( + txs []btcjson.TxRawResult, + blockNumber uint64, + targetAddress string, + logger *zerolog.Logger, + chainID int64, +) []*BTCInTxEvnet { inTxs := make([]*BTCInTxEvnet, 0) for idx, tx := range txs { if idx == 0 { continue // the first tx is coinbase; we do not process coinbase tx } - inTx, err := GetBtcEvent(tx, targetAddress, blockNumber, logger) + inTx, err := GetBtcEvent(tx, targetAddress, blockNumber, logger, chainID) if err != nil { logger.Error().Err(err).Msg("error getting btc event") continue @@ -602,7 +606,7 @@ func (ob *BitcoinChainClient) GetInboundVoteMessageFromBtcEvent(inTx *BTCInTxEvn ob.chain.ChainId, inTx.FromAddress, inTx.FromAddress, - common.ZetaChain().ChainId, + ob.zetaClient.ZetaChain().ChainId, cosmosmath.NewUintFromBigInt(amountInt), message, inTx.TxHash, @@ -611,10 +615,17 @@ func (ob *BitcoinChainClient) GetInboundVoteMessageFromBtcEvent(inTx *BTCInTxEvn common.CoinType_Gas, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), + 0, ) } -func GetBtcEvent(tx btcjson.TxRawResult, targetAddress string, blockNumber uint64, logger *zerolog.Logger) (*BTCInTxEvnet, error) { +func GetBtcEvent( + tx btcjson.TxRawResult, + targetAddress string, + blockNumber uint64, + logger *zerolog.Logger, + chainID int64, +) (*BTCInTxEvnet, error) { found := false var value float64 var memo []byte @@ -627,7 +638,12 @@ func GetBtcEvent(tx btcjson.TxRawResult, targetAddress string, blockNumber uint6 if err != nil { return nil, err } - wpkhAddress, err := btcutil.NewAddressWitnessPubKeyHash(hash, config.BitconNetParams) + + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(chainID) + if err != nil { + return nil, fmt.Errorf("btc: error getting bitcoin net params : %v", err) + } + wpkhAddress, err := btcutil.NewAddressWitnessPubKeyHash(hash, bitcoinNetParams) if err != nil { return nil, err } @@ -673,7 +689,13 @@ func GetBtcEvent(tx btcjson.TxRawResult, targetAddress string, blockNumber uint6 return nil, errors.Wrapf(err, "error decoding pubkey") } hash := btcutil.Hash160(pkBytes) - addr, err := btcutil.NewAddressWitnessPubKeyHash(hash, config.BitconNetParams) + + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(chainID) + if err != nil { + return nil, fmt.Errorf("btc: error getting bitcoin net params : %v", err) + } + + addr, err := btcutil.NewAddressWitnessPubKeyHash(hash, bitcoinNetParams) if err != nil { return nil, errors.Wrapf(err, "error decoding pubkey hash") } @@ -693,7 +715,12 @@ func GetBtcEvent(tx btcjson.TxRawResult, targetAddress string, blockNumber uint6 } func (ob *BitcoinChainClient) WatchUTXOS() { - ticker := NewDynamicTicker("Bitcoin_WatchUTXOS", ob.GetCoreParams().WatchUtxoTicker) + ticker, err := NewDynamicTicker("Bitcoin_WatchUTXOS", ob.GetCoreParams().WatchUtxoTicker) + if err != nil { + ob.logger.WatchUTXOS.Error().Err(err).Msg("WatchUTXOS error") + return + } + defer ticker.Stop() for { select { @@ -729,7 +756,11 @@ func (ob *BitcoinChainClient) FetchUTXOS() error { // List unspent. tssAddr := ob.Tss.BTCAddress() - address, err := btcutil.DecodeAddress(tssAddr, config.BitconNetParams) + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(ob.chain.ChainId) + if err != nil { + return fmt.Errorf("btc: error getting bitcoin net params : %v", err) + } + address, err := btcutil.DecodeAddress(tssAddr, bitcoinNetParams) if err != nil { return fmt.Errorf("btc: error decoding wallet address (%s) : %s", tssAddr, err.Error()) } @@ -937,11 +968,12 @@ func (ob *BitcoinChainClient) SaveBroadcastedTx(txHash string, nonce uint64) { broadcastEntry := clienttypes.ToOutTxHashSQLType(txHash, outTxID) if err := ob.db.Save(&broadcastEntry).Error; err != nil { - ob.logger.ObserveOutTx.Error().Err(err).Msg("observeOutTx: error saving broadcasted tx") + ob.logger.ObserveOutTx.Error().Err(err).Msgf("SaveBroadcastedTx: error saving broadcasted txHash %s for outTx %s", txHash, outTxID) } + ob.logger.ObserveOutTx.Info().Msgf("SaveBroadcastedTx: saved broadcasted txHash %s for outTx %s", txHash, outTxID) } -func (ob *BitcoinChainClient) GetPendingCctxParams(nonce uint64) (types.OutboundTxParams, error) { +func (ob *BitcoinChainClient) GetCctxParams(nonce uint64) (types.OutboundTxParams, error) { send, err := ob.zetaClient.GetCctxByNonce(ob.chain.ChainId, nonce) if err != nil { return types.OutboundTxParams{}, err @@ -949,14 +981,16 @@ func (ob *BitcoinChainClient) GetPendingCctxParams(nonce uint64) (types.Outbound if send.GetCurrentOutTxParam() == nil { // never happen return types.OutboundTxParams{}, fmt.Errorf("GetPendingCctx: nil outbound tx params") } - if send.CctxStatus.Status == types.CctxStatus_PendingOutbound || send.CctxStatus.Status == types.CctxStatus_PendingRevert { - return *send.GetCurrentOutTxParam(), nil - } - return types.OutboundTxParams{}, fmt.Errorf("GetPendingCctx: not a pending cctx") + return *send.GetCurrentOutTxParam(), nil } func (ob *BitcoinChainClient) observeOutTx() { - ticker := NewDynamicTicker("Bitcoin_observeOutTx", ob.GetCoreParams().OutTxTicker) + ticker, err := NewDynamicTicker("Bitcoin_observeOutTx", ob.GetCoreParams().OutTxTicker) + if err != nil { + ob.logger.ObserveOutTx.Error().Err(err).Msg("observeOutTx: error creating ticker") + return + } + defer ticker.Stop() for { select { @@ -969,9 +1003,9 @@ func (ob *BitcoinChainClient) observeOutTx() { for _, tracker := range trackers { // get original cctx parameters outTxID := ob.GetTxID(tracker.Nonce) - params, err := ob.GetPendingCctxParams(tracker.Nonce) + params, err := ob.GetCctxParams(tracker.Nonce) if err != nil { - ob.logger.ObserveOutTx.Info().Err(err).Msgf("observeOutTx: can't find pending cctx for nonce %d", tracker.Nonce) + ob.logger.ObserveOutTx.Info().Err(err).Msgf("observeOutTx: can't find cctx for nonce %d", tracker.Nonce) break } if tracker.Nonce != params.OutboundTxTssNonce { // Tanmay: it doesn't hurt to check @@ -1098,9 +1132,10 @@ func (ob *BitcoinChainClient) getRawTxResult(hash *chainhash.Hash, res *btcjson. return btcjson.TxRawResult{}, errors.Wrapf(err, "getRawTxResult: invalid outTx with invalid block index, TxID %s, BlockIndex %d", res.TxID, res.BlockIndex) } return block.Tx[res.BlockIndex], nil - } else { // res.Confirmations < 0 (meaning not included) - return btcjson.TxRawResult{}, fmt.Errorf("getRawTxResult: tx %s not included yet", hash) } + + // res.Confirmations < 0 (meaning not included) + return btcjson.TxRawResult{}, fmt.Errorf("getRawTxResult: tx %s not included yet", hash) } // checkTSSVin checks vin is valid if: diff --git a/zetaclient/bitcoin_client_test.go b/zetaclient/bitcoin_client_test.go index 4779bd9c75..49685b1f58 100644 --- a/zetaclient/bitcoin_client_test.go +++ b/zetaclient/bitcoin_client_test.go @@ -96,7 +96,13 @@ func (suite *BitcoinClientTestSuite) Test1() { suite.T().Logf("block confirmation %d", block.Confirmations) suite.T().Logf("block txs len %d", len(block.Tx)) - inTxs := FilterAndParseIncomingTx(block.Tx, uint64(block.Height), "tb1qsa222mn2rhdq9cruxkz8p2teutvxuextx3ees2", &log.Logger) + inTxs := FilterAndParseIncomingTx( + block.Tx, + uint64(block.Height), + "tb1qsa222mn2rhdq9cruxkz8p2teutvxuextx3ees2", + &log.Logger, + common.BtcRegtestChain().ChainId, + ) suite.Require().Equal(1, len(inTxs)) suite.Require().Equal(inTxs[0].Value, 0.0001) @@ -126,7 +132,13 @@ func (suite *BitcoinClientTestSuite) Test2() { suite.T().Logf("block height %d", block.Height) suite.T().Logf("block txs len %d", len(block.Tx)) - inTxs := FilterAndParseIncomingTx(block.Tx, uint64(block.Height), "tb1qsa222mn2rhdq9cruxkz8p2teutvxuextx3ees2", &log.Logger) + inTxs := FilterAndParseIncomingTx( + block.Tx, + uint64(block.Height), + "tb1qsa222mn2rhdq9cruxkz8p2teutvxuextx3ees2", + &log.Logger, + common.BtcRegtestChain().ChainId, + ) suite.Require().Equal(0, len(inTxs)) } diff --git a/zetaclient/broadcast.go b/zetaclient/broadcast.go index cf6e6e5682..d69c6c2778 100644 --- a/zetaclient/broadcast.go +++ b/zetaclient/broadcast.go @@ -6,6 +6,8 @@ import ( "strconv" "strings" + "github.com/zeta-chain/zetacore/zetaclient/hsm" + "github.com/cosmos/cosmos-sdk/client" clienttx "github.com/cosmos/cosmos-sdk/client/tx" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -58,7 +60,7 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg fee := sdktypes.NewCoins(sdktypes.NewCoin("azeta", sdktypes.NewInt(40000))) builder.SetFeeAmount(fee) //fmt.Printf("signing from name: %s\n", ctx.GetFromName()) - err = clienttx.Sign(factory, ctx.GetFromName(), builder, true) + err = b.SignTx(factory, ctx.GetFromName(), builder, true, ctx.TxConfig) if err != nil { return "", err } @@ -153,3 +155,16 @@ func (b *ZetaCoreBridge) GetContext() (client.Context, error) { ctx = ctx.WithClient(wsClient) return ctx, nil } + +func (b *ZetaCoreBridge) SignTx( + txf clienttx.Factory, + name string, + txBuilder client.TxBuilder, + overwriteSig bool, + txConfig client.TxConfig, +) error { + if b.cfg.HsmMode { + return hsm.SignWithHSM(txf, name, txBuilder, overwriteSig, txConfig) + } + return clienttx.Sign(txf, name, txBuilder, overwriteSig) +} diff --git a/zetaclient/btc_signer.go b/zetaclient/btc_signer.go index 99385842d7..f293468ee7 100644 --- a/zetaclient/btc_signer.go +++ b/zetaclient/btc_signer.go @@ -233,7 +233,7 @@ func (signer *BTCSigner) Broadcast(signedTx *wire.MsgTx) error { } func (signer *BTCSigner) TryProcessOutTx( - send *types.CrossChainTx, + cctx *types.CrossChainTx, outTxMan *OutTxProcessorManager, outTxID string, chainclient ChainClient, @@ -243,22 +243,22 @@ func (signer *BTCSigner) TryProcessOutTx( defer func() { outTxMan.EndTryProcess(outTxID) if err := recover(); err != nil { - signer.logger.Error().Msgf("BTC TryProcessOutTx: %s, caught panic error: %v", send.Index, err) + signer.logger.Error().Msgf("BTC TryProcessOutTx: %s, caught panic error: %v", cctx.Index, err) } }() logger := signer.logger.With(). Str("OutTxID", outTxID). - Str("SendHash", send.Index). + Str("SendHash", cctx.Index). Logger() - params := send.GetCurrentOutTxParam() + params := cctx.GetCurrentOutTxParam() if params.CoinType == common.CoinType_Zeta || params.CoinType == common.CoinType_ERC20 { logger.Error().Msgf("BTC TryProcessOutTx: can only send BTC to a BTC network") return } - logger.Info().Msgf("BTC TryProcessOutTx: %s, value %d to %s", send.Index, params.Amount.BigInt(), params.Receiver) + logger.Info().Msgf("BTC TryProcessOutTx: %s, value %d to %s", cctx.Index, params.Amount.BigInt(), params.Receiver) btcClient, ok := chainclient.(*BitcoinChainClient) if !ok { logger.Error().Msgf("chain client is not a bitcoin client") @@ -277,9 +277,9 @@ func (signer *BTCSigner) TryProcessOutTx( // Early return if the send is already processed // FIXME: handle revert case outboundTxTssNonce := params.OutboundTxTssNonce - included, confirmed, err := btcClient.IsSendOutTxProcessed(send.Index, outboundTxTssNonce, common.CoinType_Gas, logger) + included, confirmed, err := btcClient.IsSendOutTxProcessed(cctx.Index, outboundTxTssNonce, common.CoinType_Gas, logger) if err != nil { - logger.Error().Err(err).Msgf("cannot check if send %s is processed", send.Index) + logger.Error().Err(err).Msgf("cannot check if send %s is processed", cctx.Index) return } if included || confirmed { @@ -294,18 +294,41 @@ func (signer *BTCSigner) TryProcessOutTx( return } - // FIXME: config chain params - addr, err := btcutil.DecodeAddress(params.Receiver, config.BitconNetParams) + // Check receiver P2WPKH address + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(params.ReceiverChainId) + if err != nil { + logger.Error().Err(err).Msgf("cannot get bitcoin net params%v", err) + return + } + + addr, err := btcutil.DecodeAddress(params.Receiver, bitcoinNetParams) if err != nil { logger.Error().Err(err).Msgf("cannot decode address %s ", params.Receiver) return } + if !addr.IsForNet(bitcoinNetParams) { + logger.Error().Msgf( + "address %s is not for network %s", + params.Receiver, + bitcoinNetParams.Name, + ) + return + } to, ok := addr.(*btcutil.AddressWitnessPubKeyHash) if err != nil || !ok { logger.Error().Err(err).Msgf("cannot convert address %s to P2WPKH address", params.Receiver) return } + // Add 1 satoshi/byte to gasPrice to avoid minRelayTxFee issue + networkInfo, err := signer.rpcClient.GetNetworkInfo() + if err != nil { + logger.Error().Err(err).Msgf("cannot get bitcoin network info") + return + } + satPerByte := feeRateToSatPerByte(networkInfo.RelayFee) + gasprice.Add(gasprice, satPerByte) + logger.Info().Msgf("SignWithdrawTx: to %s, value %d sats", addr.EncodeAddress(), params.Amount.Uint64()) logger.Info().Msgf("using utxos: %v", btcClient.utxos) @@ -323,7 +346,8 @@ func (signer *BTCSigner) TryProcessOutTx( logger.Warn().Err(err).Msgf("SignOutboundTx error: nonce %d chain %d", outboundTxTssNonce, params.ReceiverChainId) return } - logger.Info().Msgf("Key-sign success: %d => %s, nonce %d", send.InboundTxParams.SenderChainId, btcClient.chain.ChainName, outboundTxTssNonce) + logger.Info().Msgf("Key-sign success: %d => %s, nonce %d", cctx.InboundTxParams.SenderChainId, btcClient.chain.ChainName, outboundTxTssNonce) + // FIXME: add prometheus metrics _, err = zetaBridge.GetObserverList(btcClient.chain) if err != nil { diff --git a/zetaclient/config/config_testnet.go b/zetaclient/config/config_chain.go similarity index 94% rename from zetaclient/config/config_testnet.go rename to zetaclient/config/config_chain.go index 5a3bf948e0..f932be7305 100644 --- a/zetaclient/config/config_testnet.go +++ b/zetaclient/config/config_chain.go @@ -1,29 +1,18 @@ -//go:build TESTNET -// +build TESTNET - package config import ( - "github.com/btcsuite/btcd/chaincfg" "github.com/zeta-chain/zetacore/common" ) const ( + BtcConfirmationCount = 1 + DevEthConfirmationCount = 2 + + // TssTestPrivkey is the private key of the TSS address + // #nosec G101 - used for testing only TssTestPrivkey = "2082bc9775d6ee5a05ef221a9d1c00b3cc3ecb274a4317acc0a182bc1e05d1bb" TssTestAddress = "0xE80B6467863EbF8865092544f441da8fD3cF6074" - //TestReceiver = "0x566bF3b1993FFd4BA134c107A63bb2aebAcCdbA0" -) - -// Constants -// #nosec G101 -const ( - - // Ticker timers - EthBlockTime = 12 - PolygonBlockTime = 2 - BscBlockTime = 5 - // to catch up: MaxBlocksPerPeriod = 100 ) @@ -34,33 +23,36 @@ const ( [{"inputs":[{"internalType":"address","name":"_TSSAddress","type":"address"},{"internalType":"address","name":"_TSSAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidTSSUpdater","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"NotPaused","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"recipient","type":"bytes"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Unwhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Whitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"TSSAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TSSAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"recipient","type":"bytes"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTSSAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"unwhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateTSSAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"whitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]` ) -var ( - BitconNetParams = &chaincfg.TestNet3Params -) - func GetConnectorABI() string { return ConnectorAbiString } + func GetERC20CustodyABI() string { return ERC20CustodyAbiString } -var BitcoinConfig = &BTCConfig{ - RPCUsername: "smoketest", - RPCPassword: "123", - RPCHost: "bitcoin:18443", - RPCParams: "regtest", -} - func New() Config { return Config{ - BitcoinConfig: BitcoinConfig, - EVMChainConfigs: evmChainsConfig, + EVMChainConfigs: evmChainsConfigs, + BitcoinConfig: bitcoinConfigRegnet, ChainsEnabled: []common.Chain{}, } } -var evmChainsConfig = map[int64]*EVMConfig{ +var bitcoinConfigRegnet = &BTCConfig{ + RPCUsername: "smoketest", + RPCPassword: "123", + RPCHost: "bitcoin:18443", + RPCParams: "regtest", +} + +var evmChainsConfigs = map[int64]*EVMConfig{ + common.EthChain().ChainId: { + Chain: common.EthChain(), + }, + common.BscMainnetChain().ChainId: { + Chain: common.BscMainnetChain(), + }, common.GoerliChain().ChainId: { Chain: common.GoerliChain(), Endpoint: "", @@ -73,4 +65,8 @@ var evmChainsConfig = map[int64]*EVMConfig{ Chain: common.MumbaiChain(), Endpoint: "", }, + common.GoerliLocalnetChain().ChainId: { + Chain: common.GoerliLocalnetChain(), + Endpoint: "http://eth:8545", + }, } diff --git a/zetaclient/config/config_mainnet.go b/zetaclient/config/config_mainnet.go deleted file mode 100644 index 646b8b3460..0000000000 --- a/zetaclient/config/config_mainnet.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build !PRIVNET && !TESTNET && !MOCK_MAINNET -// +build !PRIVNET,!TESTNET,!MOCK_MAINNET - -package config - -import ( - "github.com/btcsuite/btcd/chaincfg" - "github.com/zeta-chain/zetacore/common" -) - -const ( - BtcConfirmationCount = 1 - DevEthConfirmationCount = 2 -) - -const ( - // #nosec - TssTestPrivkey = "2082bc9775d6ee5a05ef221a9d1c00b3cc3ecb274a4317acc0a182bc1e05d1bb" - TssTestAddress = "0xE80B6467863EbF8865092544f441da8fD3cF6074" -) - -// Constants -// #nosec G101 -const ( - MaxBlocksPerPeriod = 100 -) - -const ( - ConnectorAbiString = ` -[{"inputs":[{"internalType":"address","name":"_zetaTokenAddress","type":"address"},{"internalType":"address","name":"_tssAddress","type":"address"},{"internalType":"address","name":"_tssAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"indexed":true,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":true,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"zetaParams","type":"bytes"}],"name":"ZetaSent","type":"event"},{"inputs":[],"name":"getLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originSenderAddress","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTssAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"zetaParams","type":"bytes"}],"internalType":"struct ZetaInterfaces.SendInput","name":"input","type":"tuple"}],"name":"send","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tssAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tssAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tssAddress","type":"address"}],"name":"updateTssAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zetaToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` - ERC20CustodyAbiString = ` -[{"inputs":[{"internalType":"address","name":"_TSSAddress","type":"address"},{"internalType":"address","name":"_TSSAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidTSSUpdater","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"NotPaused","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"recipient","type":"bytes"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Unwhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Whitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"TSSAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TSSAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"recipient","type":"bytes"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTSSAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"unwhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateTSSAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"whitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]` -) - -func GetConnectorABI() string { - return ConnectorAbiString -} -func GetERC20CustodyABI() string { - return ERC20CustodyAbiString -} - -var ( - BitconNetParams = &chaincfg.MainNetParams -) - -func New() Config { - return Config{ - EVMChainConfigs: evmChainConfigs, - BitcoinConfig: BitcoinConfig, - ChainsEnabled: []common.Chain{}, - } -} - -var BitcoinConfig = &BTCConfig{} - -var evmChainConfigs = map[int64]*EVMConfig{ - common.EthChain().ChainId: { - Chain: common.EthChain(), - }, - common.BscMainnetChain().ChainId: { - Chain: common.BscMainnetChain(), - }, -} diff --git a/zetaclient/config/config_mock_mainnet.go b/zetaclient/config/config_mock_mainnet.go deleted file mode 100644 index fe7195d1cd..0000000000 --- a/zetaclient/config/config_mock_mainnet.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build MOCK_MAINNET -// +build MOCK_MAINNET - -package config - -import ( - "github.com/btcsuite/btcd/chaincfg" - "github.com/zeta-chain/zetacore/common" -) - -const ( - BtcConfirmationCount = 1 - DevEthConfirmationCount = 2 -) - -const ( - // #nosec G101 - TssTestPrivkey = "2082bc9775d6ee5a05ef221a9d1c00b3cc3ecb274a4317acc0a182bc1e05d1bb" - TssTestAddress = "0xE80B6467863EbF8865092544f441da8fD3cF6074" -) - -// Constants -// #nosec G101 -const ( - MaxBlocksPerPeriod = 100 -) - -const ( - ConnectorAbiString = ` -[{"inputs":[{"internalType":"address","name":"_zetaTokenAddress","type":"address"},{"internalType":"address","name":"_tssAddress","type":"address"},{"internalType":"address","name":"_tssAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"indexed":true,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":true,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"zetaParams","type":"bytes"}],"name":"ZetaSent","type":"event"},{"inputs":[],"name":"getLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originSenderAddress","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTssAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"zetaParams","type":"bytes"}],"internalType":"struct ZetaInterfaces.SendInput","name":"input","type":"tuple"}],"name":"send","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tssAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tssAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tssAddress","type":"address"}],"name":"updateTssAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zetaToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` - ERC20CustodyAbiString = ` -[{"inputs":[{"internalType":"address","name":"_TSSAddress","type":"address"},{"internalType":"address","name":"_TSSAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidTSSUpdater","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"NotPaused","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"recipient","type":"bytes"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Unwhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Whitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"TSSAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TSSAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"recipient","type":"bytes"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTSSAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"unwhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateTSSAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"whitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]` -) - -func GetConnectorABI() string { - return ConnectorAbiString -} -func GetERC20CustodyABI() string { - return ERC20CustodyAbiString -} - -var ( - BitconNetParams = &chaincfg.MainNetParams -) - -func New() Config { - return Config{ - EVMChainConfigs: evmChainConfigs, - BitcoinConfig: BitcoinConfig, - ChainsEnabled: []common.Chain{}, - } -} - -var BitcoinConfig = &BTCConfig{} - -var evmChainConfigs = map[int64]*EVMConfig{ - common.EthChain().ChainId: { - Chain: common.EthChain(), - }, - common.BscMainnetChain().ChainId: { - Chain: common.BscMainnetChain(), - }, -} diff --git a/zetaclient/config/config_privnet.go b/zetaclient/config/config_privnet.go deleted file mode 100644 index d801c8dbd7..0000000000 --- a/zetaclient/config/config_privnet.go +++ /dev/null @@ -1,62 +0,0 @@ -//go:build PRIVNET -// +build PRIVNET - -package config - -import ( - "github.com/btcsuite/btcd/chaincfg" - "github.com/zeta-chain/zetacore/common" -) - -const ( - TssTestPrivkey = "2082bc9775d6ee5a05ef221a9d1c00b3cc3ecb274a4317acc0a182bc1e05d1bb" - TssTestAddress = "0xE80B6467863EbF8865092544f441da8fD3cF6074" -) - -// Constants -// #nosec G101 -const ( - // to catch up: - MaxBlocksPerPeriod = 100 -) - -const ( - ConnectorAbiString = ` -[{"inputs":[{"internalType":"address","name":"_zetaTokenAddress","type":"address"},{"internalType":"address","name":"_tssAddress","type":"address"},{"internalType":"address","name":"_tssAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"indexed":true,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"destinationAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"originChainId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":true,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"ZetaReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"originSenderAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"zetaParams","type":"bytes"}],"name":"ZetaSent","type":"event"},{"inputs":[],"name":"getLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"originSenderAddress","type":"bytes"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originSenderAddress","type":"address"},{"internalType":"uint256","name":"originChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes32","name":"internalSendHash","type":"bytes32"}],"name":"onRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTssAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"bytes","name":"destinationAddress","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"uint256","name":"zetaAmount","type":"uint256"},{"internalType":"bytes","name":"zetaParams","type":"bytes"}],"internalType":"struct ZetaInterfaces.SendInput","name":"input","type":"tuple"}],"name":"send","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tssAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tssAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tssAddress","type":"address"}],"name":"updateTssAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zetaToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` - ERC20CustodyAbiString = ` -[{"inputs":[{"internalType":"address","name":"_TSSAddress","type":"address"},{"internalType":"address","name":"_TSSAddressUpdater","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidTSSUpdater","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"NotPaused","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"recipient","type":"bytes"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Unwhitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"Whitelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"TSSAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TSSAddressUpdater","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"recipient","type":"bytes"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceTSSAddressUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"unwhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"updateTSSAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"whitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]` -) - -func GetConnectorABI() string { - return ConnectorAbiString -} -func GetERC20CustodyABI() string { - return ERC20CustodyAbiString -} - -var ( - BitconNetParams = &chaincfg.RegressionNetParams -) - -var bitcoinConfig = &BTCConfig{ - RPCUsername: "smoketest", - RPCPassword: "123", - RPCHost: "bitcoin:18443", - RPCParams: "regtest", -} - -func New() Config { - return Config{ - ChainsEnabled: []common.Chain{}, - EVMChainConfigs: evmChainConfigs, - BitcoinConfig: bitcoinConfig, - } -} - -var evmChainConfigs = map[int64]*EVMConfig{ - - common.GoerliChain().ChainId: { - Chain: common.GoerliChain(), - Endpoint: "http://eth:8545", - }, -} diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index 33d3763d8c..8ae117f138 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -27,7 +27,8 @@ type ClientConfiguration struct { ChainRPC string `json:"chain_rpc" mapstructure:"chain_rpc"` ChainHomeFolder string `json:"chain_home_folder" mapstructure:"chain_home_folder"` SignerName string `json:"signer_name" mapstructure:"signer_name"` - SignerPasswd string + SignerPasswd string `json:"signer_passwd"` + HsmMode bool `json:"hsm_mode"` } type EVMConfig struct { @@ -68,6 +69,8 @@ type Config struct { TestTssKeysign bool `json:"TestTssKeysign"` CurrentTssPubkey string `json:"CurrentTssPubkey"` KeyringBackend KeyringBackend `json:"KeyringBackend"` + HsmMode bool `json:"HsmMode"` + HsmHotKey string `json:"HsmHotKey"` // chain specific fields are updatable at runtime and shared across threads cfgLock *sync.RWMutex `json:"-"` @@ -188,10 +191,12 @@ func (c *Config) UpdateCoreParams( } c.Keygen = *keygen c.ChainsEnabled = newChains - if c.BitcoinConfig != nil && btcCoreParams != nil { // update core params for bitcoin if it has config in file + // update core params for bitcoin if it has config in file + if c.BitcoinConfig != nil && btcCoreParams != nil { c.BitcoinConfig.CoreParams = *btcCoreParams } - for _, params := range evmCoreParams { // update core params for evm chains we have configs in file + // update core params for evm chains we have configs in file + for _, params := range evmCoreParams { curCfg, found := c.EVMChainConfigs[params.ChainId] if found { curCfg.CoreParams = *params diff --git a/zetaclient/evm_client.go b/zetaclient/evm_client.go index 6ed9476192..1a44a3c804 100644 --- a/zetaclient/evm_client.go +++ b/zetaclient/evm_client.go @@ -13,6 +13,9 @@ import ( "time" "github.com/ethereum/go-ethereum" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.non-eth.sol" + zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol" + "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -232,14 +235,33 @@ func (ob *EVMChainClient) GetConnectorContract() (*zetaconnector.ZetaConnectorNo return FetchConnectorContract(addr, ob.evmClient) } -func FetchConnectorContract(addr ethcommon.Address, client EVMRPCClient) (*zetaconnector.ZetaConnectorNonEth, error) { - return zetaconnector.NewZetaConnectorNonEth(addr, client) +func (ob *EVMChainClient) GetConnectorContractEth() (*zetaconnectoreth.ZetaConnectorEth, error) { + addr := ethcommon.HexToAddress(ob.GetCoreParams().ConnectorContractAddress) + return FetchConnectorContractEth(addr, ob.evmClient) } + +func (ob *EVMChainClient) GetZetaTokenNonEthContract() (*zeta.ZetaNonEth, error) { + addr := ethcommon.HexToAddress(ob.GetCoreParams().ZetaTokenContractAddress) + return FetchZetaZetaNonEthTokenContract(addr, ob.evmClient) +} + func (ob *EVMChainClient) GetERC20CustodyContract() (*erc20custody.ERC20Custody, error) { addr := ethcommon.HexToAddress(ob.GetCoreParams().Erc20CustodyContractAddress) return FetchERC20CustodyContract(addr, ob.evmClient) } +func FetchConnectorContract(addr ethcommon.Address, client EVMRPCClient) (*zetaconnector.ZetaConnectorNonEth, error) { + return zetaconnector.NewZetaConnectorNonEth(addr, client) +} + +func FetchConnectorContractEth(addr ethcommon.Address, client EVMRPCClient) (*zetaconnectoreth.ZetaConnectorEth, error) { + return zetaconnectoreth.NewZetaConnectorEth(addr, client) +} + +func FetchZetaZetaNonEthTokenContract(addr ethcommon.Address, client EVMRPCClient) (*zeta.ZetaNonEth, error) { + return zeta.NewZetaNonEth(addr, client) +} + func FetchERC20CustodyContract(addr ethcommon.Address, client EVMRPCClient) (*erc20custody.ERC20Custody, error) { return erc20custody.NewERC20Custody(addr, client) } @@ -302,7 +324,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Cmd, ) if err != nil { - logger.Error().Err(err).Msg("error posting confirmation to meta core") + logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaHash, sendHash, nonce) return true, true, nil @@ -323,7 +345,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Gas, ) if err != nil { - logger.Error().Err(err).Msg("error posting confirmation to meta core") + logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaHash, sendHash, nonce) return true, true, nil @@ -343,7 +365,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Gas, ) if err != nil { - logger.Error().Err(err).Msgf("PostReceiveConfirmation error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash) + logger.Error().Err(err).Msgf("PostReceiveConfirmation error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) return true, true, nil @@ -388,7 +410,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Zeta, ) if err != nil { - logger.Error().Err(err).Msg("error posting confirmation to meta core") + logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) continue } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaHash, sendHash, nonce) @@ -424,7 +446,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Zeta, ) if err != nil { - logger.Err(err).Msg("error posting confirmation to meta core") + logger.Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) continue } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", metaHash, sendHash, nonce) @@ -452,7 +474,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_Zeta, ) if err != nil { - logger.Error().Err(err).Msgf("PostReceiveConfirmation error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash) + logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) return true, true, nil @@ -490,7 +512,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co common.CoinType_ERC20, ) if err != nil { - logger.Error().Err(err).Msg("error posting confirmation to meta core") + logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) continue } logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d", zetaHash, sendHash, nonce) @@ -529,9 +551,9 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co // The lowest nonce we observe outTx for each chain var lowestOutTxNonceToObserve = map[int64]uint64{ - 5: 70000, // Goerli - 97: 95000, // BSC testnet - 80001: 120000, // Mumbai + 5: 113000, // Goerli + 97: 102600, // BSC testnet + 80001: 154500, // Mumbai } // FIXME: there's a chance that a txhash in OutTxChan may not deliver when Stop() is called @@ -548,7 +570,12 @@ func (ob *EVMChainClient) observeOutTx() { } ob.logger.ObserveOutTx.Info().Msgf("observeOutTx using timeoutNonce %d seconds, rpcRestTime %d ms", timeoutNonce, rpcRestTime) - ticker := NewDynamicTicker(fmt.Sprintf("EVM_observeOutTx_%d", ob.chain.ChainId), ob.GetCoreParams().OutTxTicker) + ticker, err := NewDynamicTicker(fmt.Sprintf("EVM_observeOutTx_%d", ob.chain.ChainId), ob.GetCoreParams().OutTxTicker) + if err != nil { + ob.logger.ObserveOutTx.Error().Err(err).Msg("failed to create ticker") + return + } + defer ticker.Stop() for { select { @@ -566,21 +593,18 @@ func (ob *EVMChainClient) observeOutTx() { if nonceInt < lowestOutTxNonceToObserve[ob.chain.ChainId] { continue } - TXHASHLOOP: + ob.Mu.Lock() + _, found := ob.outTXConfirmedReceipts[ob.GetTxID(nonceInt)] + ob.Mu.Unlock() + if found { // Go to next tracker if this one has already been confirmed + continue + } for _, txHash := range tracker.HashList { - //inTimeout := time.After(3000 * time.Millisecond) select { case <-outTimeout: ob.logger.ObserveOutTx.Warn().Msgf("observeOutTx timeout on chain %d nonce %d", ob.chain.ChainId, nonceInt) break TRACKERLOOP default: - ob.Mu.Lock() - _, found := ob.outTXConfirmedReceipts[ob.GetTxID(nonceInt)] - ob.Mu.Unlock() - if found { - continue - } - receipt, transaction, err := ob.queryTxByHash(txHash.TxHash, nonceInt) time.Sleep(time.Duration(rpcRestTime) * time.Millisecond) if err == nil && receipt != nil { // confirmed @@ -588,13 +612,13 @@ func (ob *EVMChainClient) observeOutTx() { ob.outTXConfirmedReceipts[ob.GetTxID(nonceInt)] = receipt ob.outTXConfirmedTransaction[ob.GetTxID(nonceInt)] = transaction ob.Mu.Unlock() + ob.logger.ObserveOutTx.Info().Msgf("observeOutTx confirmed outTx %s for chain %d nonce %d", txHash.TxHash, ob.chain.ChainId, nonceInt) - break TXHASHLOOP + break } if err != nil { ob.logger.ObserveOutTx.Debug().Err(err).Msgf("error queryTxByHash: chain %s hash %s", ob.chain.String(), txHash.TxHash) } - //<-inTimeout } } } @@ -621,7 +645,7 @@ func (ob *EVMChainClient) queryTxByHash(txHash string, nonce uint64) (*ethtypes. receipt, err := ob.evmClient.TransactionReceipt(ctxt, ethcommon.HexToHash(txHash)) if err != nil { if err != ethereum.NotFound { - logger.Warn().Err(err).Msg("TransactionReceipt/TransactionByHash error") + logger.Warn().Err(err).Msgf("TransactionReceipt/TransactionByHash error, txHash %s", txHash) } return nil, nil, err } @@ -694,7 +718,12 @@ func (ob *EVMChainClient) GetLastBlockHeight() int64 { func (ob *EVMChainClient) ExternalChainWatcher() { // At each tick, query the Connector contract - ticker := NewDynamicTicker(fmt.Sprintf("EVM_ExternalChainWatcher_%d", ob.chain.ChainId), ob.GetCoreParams().InTxTicker) + ticker, err := NewDynamicTicker(fmt.Sprintf("EVM_ExternalChainWatcher_%d", ob.chain.ChainId), ob.GetCoreParams().InTxTicker) + if err != nil { + ob.logger.ExternalChainWatcher.Error().Err(err).Msg("NewDynamicTicker error") + return + } + defer ticker.Stop() ob.logger.ExternalChainWatcher.Info().Msg("ExternalChainWatcher started") for { @@ -981,12 +1010,18 @@ func (ob *EVMChainClient) WatchGasPrice() { ob.logger.WatchGasPrice.Error().Err(err).Msgf("PostGasPrice error at zeta block : %d ", height) } } - ticker := NewDynamicTicker(fmt.Sprintf("EVM_WatchGasPrice_%d", ob.chain.ChainId), ob.GetCoreParams().GasPriceTicker) + + ticker, err := NewDynamicTicker(fmt.Sprintf("EVM_WatchGasPrice_%d", ob.chain.ChainId), ob.GetCoreParams().GasPriceTicker) + if err != nil { + ob.logger.WatchGasPrice.Error().Err(err).Msg("NewDynamicTicker error") + return + } + defer ticker.Stop() for { select { case <-ticker.C(): - err := ob.PostGasPrice() + err = ob.PostGasPrice() if err != nil { height, err := ob.zetaClient.GetBlockHeight() if err != nil { diff --git a/zetaclient/evm_signer.go b/zetaclient/evm_signer.go index e00741fb10..7ea8b841b6 100644 --- a/zetaclient/evm_signer.go +++ b/zetaclient/evm_signer.go @@ -449,7 +449,7 @@ func (signer *EVMSigner) TryProcessOutTx( return } tx, err = signer.SignCommandTx(msg[0], msg[1], to, send.GetCurrentOutTxParam(), gasLimit, gasprice, height) - } else if send.InboundTxParams.SenderChainId == common.ZetaChain().ChainId && send.CctxStatus.Status == types.CctxStatus_PendingOutbound && flags.IsOutboundEnabled { + } else if send.InboundTxParams.SenderChainId == zetaBridge.ZetaChain().ChainId && send.CctxStatus.Status == types.CctxStatus_PendingOutbound && flags.IsOutboundEnabled { if send.GetCurrentOutTxParam().CoinType == common.CoinType_Gas { logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasprice %d", send.InboundTxParams.SenderChainId, toChain, send.GetCurrentOutTxParam().OutboundTxTssNonce, gasprice) tx, err = signer.SignWithdrawTx( @@ -488,7 +488,7 @@ func (signer *EVMSigner) TryProcessOutTx( height, ) } - } else if send.CctxStatus.Status == types.CctxStatus_PendingRevert && send.OutboundTxParams[0].ReceiverChainId == common.ZetaChain().ChainId { + } else if send.CctxStatus.Status == types.CctxStatus_PendingRevert && send.OutboundTxParams[0].ReceiverChainId == zetaBridge.ZetaChain().ChainId { if send.GetCurrentOutTxParam().CoinType == common.CoinType_Gas { logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasprice %d", send.InboundTxParams.SenderChainId, toChain, send.GetCurrentOutTxParam().OutboundTxTssNonce, gasprice) tx, err = signer.SignWithdrawTx( diff --git a/zetaclient/hsm/hsm_signer.go b/zetaclient/hsm/hsm_signer.go new file mode 100644 index 0000000000..06cb9e092b --- /dev/null +++ b/zetaclient/hsm/hsm_signer.go @@ -0,0 +1,167 @@ +package hsm + +import ( + "os" + + "github.com/cosmos/cosmos-sdk/client" + clienttx "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/frumioj/crypto11" + "github.com/pkg/errors" + keystone "github.com/zeta-chain/keystone/keys" +) + +const hsmPath = "HSM_PATH" +const hsmPIN = "HSM_PIN" +const hsmLabel = "HSM_LABEL" + +// Sign Generates signature of msg using the key indexed by the label through the HSM defined in the config +func Sign(config *crypto11.Config, msg []byte, label string) (signature []byte, err error) { + keyring, err := keystone.NewPkcs11(config) + if err != nil { + return + } + key, err := keyring.Key(label) + if err != nil { + return + } + return key.Sign(msg, nil) +} + +// GenerateKey This generates a new key using one of the supported algorithms and a label identifier through the HSM +func GenerateKey(label string, algorithm keystone.KeygenAlgorithm, config *crypto11.Config) (*keystone.CryptoKey, error) { + keyring, err := keystone.NewPkcs11(config) + if err != nil { + return nil, err + } + return keyring.NewKey(algorithm, label) +} + +// GetHSMAddress This address is generated by secp256k1 curve from cosmos sdk +func GetHSMAddress(config *crypto11.Config, label string) (types.Address, types.PubKey, error) { + keyring, err := keystone.NewPkcs11(config) + if err != nil { + return nil, nil, err + } + key, err := keyring.Key(label) + if err != nil { + return nil, nil, err + } + pubKey := key.PubKey() + return pubKey.Address(), pubKey, nil +} + +// SignWithHSM signs a given tx with a named key. +// This is adapted from github.com/cosmos/cosmos-sdk/client/tx Sign() function; Modified to use an HSM. +// The resulting signature will be added to the transaction builder overwriting the previous +// ones if overwrite=true (otherwise, the signature will be appended). +// Signing a transaction with multiple signers in the DIRECT mode is not supported and will +// return an error. +// An error is returned upon failure. +func SignWithHSM( + txf clienttx.Factory, + name string, + txBuilder client.TxBuilder, + overwriteSig bool, + txConfig client.TxConfig, +) error { + hsmCfg, err := GetPKCS11Config() + if err != nil { + return err + } + + address, pubKey, err := GetHSMAddress(hsmCfg, name) + if err != nil { + return err + } + + signerData := authsigning.SignerData{ + ChainID: txf.ChainID(), + AccountNumber: txf.AccountNumber(), + Sequence: txf.Sequence(), + PubKey: pubKey, + Address: sdk.AccAddress(address).String(), + } + + signMode := txf.SignMode() + + // For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on + // TxBuilder under the hood, and SignerInfos is needed to generate the + // sign bytes. This is the reason for setting SetSignatures here, with a + // nil signature. + // + // Note: this line is not needed for SIGN_MODE_LEGACY_AMINO, but putting it + // also doesn't affect its generated sign bytes, so for code's simplicity + // sake, we put it here. + sigData := signing.SingleSignatureData{ + SignMode: signMode, + Signature: nil, + } + sig := signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: txf.Sequence(), + } + + var prevSignatures []signing.SignatureV2 + if !overwriteSig { + prevSignatures, err = txBuilder.GetTx().GetSignaturesV2() + if err != nil { + return err + } + } + // Overwrite or append signer infos. + var sigs []signing.SignatureV2 + if overwriteSig { + sigs = []signing.SignatureV2{sig} + } else { + sigs = append(prevSignatures, sig) //nolint:gocritic + } + if err := txBuilder.SetSignatures(sigs...); err != nil { + return err + } + + // Generate the bytes to be signed. + bytesToSign, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx()) + if err != nil { + return err + } + + // Sign those bytes + sigBytes, err := Sign(hsmCfg, bytesToSign, name) + if err != nil { + return err + } + + // Construct the SignatureV2 struct + sigData = signing.SingleSignatureData{ + SignMode: signMode, + Signature: sigBytes, + } + sig = signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: txf.Sequence(), + } + + if overwriteSig { + return txBuilder.SetSignatures(sig) + } + prevSignatures = append(prevSignatures, sig) + return txBuilder.SetSignatures(prevSignatures...) +} + +func GetPKCS11Config() (config *crypto11.Config, err error) { + config = &crypto11.Config{} + config.Path = os.Getenv(hsmPath) + config.Pin = os.Getenv(hsmPIN) + config.TokenLabel = os.Getenv(hsmLabel) + + if config.Path == "" || config.Pin == "" || config.TokenLabel == "" { + err = errors.New("error getting pkcs11 config, make sure env variables are set") + } + return +} diff --git a/zetaclient/hsm/hsm_signer_test.go b/zetaclient/hsm/hsm_signer_test.go new file mode 100644 index 0000000000..5c7ba38099 --- /dev/null +++ b/zetaclient/hsm/hsm_signer_test.go @@ -0,0 +1,73 @@ +//go:build hsm_test +// +build hsm_test + +package hsm + +import ( + "crypto/rand" + "log" + "testing" + + "github.com/frumioj/crypto11" + + btcsecp256k1 "github.com/btcsuite/btcd/btcec" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/stretchr/testify/require" + keystone "github.com/zeta-chain/keystone/keys" +) + +func TestSignSecp256k1(t *testing.T) { + // PKCS11 configuration file + config := &crypto11.Config{ + Path: "/usr/local/lib/softhsm/libsofthsm2.so", + TokenLabel: "My token 1", + Pin: "1234", + } + + //Generate random label for key + label, err := randomBytes(16) + require.NoError(t, err) + + //Generate key + key, err := GenerateKey(string(label), keystone.KEYGEN_SECP256K1, config) + require.NoError(t, err) + require.NotNil(t, key) + + //Create sample message + msg := []byte("Signing this plaintext tells me what exactly?") + + signature, err := Sign(config, msg, string(label)) + require.NoError(t, err) + require.NotNil(t, signature) + require.Equal(t, key.KeyType(), keystone.KEYGEN_SECP256K1) + + pubkey := key.PubKey() + secp256k1key := pubkey.(*secp256k1.PubKey) + pub, err := btcsecp256k1.ParsePubKey(secp256k1key.Key, btcsecp256k1.S256()) + + log.Printf("Pub: %v", pub) + + // Validate the signature made by the HSM key, but using the + // BTC secp256k1 public key + valid := secp256k1key.VerifySignature(msg, signature) + log.Printf("Did the signature verify? True = yes: %v", valid) + log.Printf("TM blockchain address from pubkey: %v", secp256k1key.Address()) + + address, pubKey, err := GetHSMAddress(config, string(label)) + log.Printf("Address from HSM: %v, PubKey from HSM: %v", address, pubKey) + + err = key.Delete() + require.NoError(t, err) +} + +func randomBytes(n int) ([]byte, error) { + b := make([]byte, n) + _, err := rand.Read(b) + + if err != nil { + log.Printf("Error reading random bytes: %s", err.Error()) + return nil, err + } + + return b, nil +} diff --git a/zetaclient/inbound_tracker.go b/zetaclient/inbound_tracker.go index 8e6c7c01d2..1181a14747 100644 --- a/zetaclient/inbound_tracker.go +++ b/zetaclient/inbound_tracker.go @@ -16,7 +16,12 @@ import ( // ExternalChainWatcherForNewInboundTrackerSuggestions At each tick, gets a list of Inbound tracker suggestions from zeta-core and tries to check if the in-tx was confirmed. // If it was, it tries to broadcast the confirmation vote. If this zeta client has previously broadcast the vote, the tx would be rejected func (ob *EVMChainClient) ExternalChainWatcherForNewInboundTrackerSuggestions() { - ticker := NewDynamicTicker(fmt.Sprintf("EVM_ExternalChainWatcher_InboundTrackerSuggestions_%d", ob.chain.ChainId), ob.GetCoreParams().InTxTicker) + ticker, err := NewDynamicTicker(fmt.Sprintf("EVM_ExternalChainWatcher_InboundTrackerSuggestions_%d", ob.chain.ChainId), ob.GetCoreParams().InTxTicker) + if err != nil { + ob.logger.ExternalChainWatcher.Err(err).Msg("error creating ticker") + return + } + defer ticker.Stop() ob.logger.ExternalChainWatcher.Info().Msg("ExternalChainWatcher for inboundTrackerSuggestions started") for { @@ -35,7 +40,12 @@ func (ob *EVMChainClient) ExternalChainWatcherForNewInboundTrackerSuggestions() } func (ob *BitcoinChainClient) ExternalChainWatcherForNewInboundTrackerSuggestions() { - ticker := NewDynamicTicker("Bitcoin_WatchInTx_InboundTrackerSuggestions", ob.GetCoreParams().InTxTicker) + ticker, err := NewDynamicTicker("Bitcoin_WatchInTx_InboundTrackerSuggestions", ob.GetCoreParams().InTxTicker) + if err != nil { + ob.logger.WatchInTx.Err(err).Msg("error creating ticker") + return + } + defer ticker.Stop() for { select { @@ -90,7 +100,7 @@ func (ob *BitcoinChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool) return "", err } // #nosec G701 always positive - event, err := GetBtcEvent(*tx, tss, uint64(block.Height), &ob.logger.WatchInTx) + event, err := GetBtcEvent(*tx, tss, uint64(block.Height), &ob.logger.WatchInTx, ob.chain.ChainId) if err != nil { return "", err } diff --git a/zetaclient/interfaces.go b/zetaclient/interfaces.go index 49f64f68bb..51d84f5927 100644 --- a/zetaclient/interfaces.go +++ b/zetaclient/interfaces.go @@ -87,12 +87,14 @@ type ZetaCoreBridger interface { GetBtcTssAddress() (string, error) GetInboundTrackersForChain(chainID int64) ([]crosschaintypes.InTxTracker, error) GetLogger() *zerolog.Logger + ZetaChain() common.Chain Pause() Unpause() } // BTCRPCClient is the interface for BTC RPC client type BTCRPCClient interface { + GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) diff --git a/zetaclient/query.go b/zetaclient/query.go index 3e8a13af9f..76d4573572 100644 --- a/zetaclient/query.go +++ b/zetaclient/query.go @@ -6,10 +6,16 @@ import ( "sort" "time" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/types/query" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" + tmhttp "github.com/tendermint/tendermint/rpc/client/http" + "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -130,6 +136,42 @@ func (b *ZetaCoreBridge) GetAllPendingCctx(chainID int64) ([]*types.CrossChainTx return resp.CrossChainTx, nil } +func (b *ZetaCoreBridge) GetCctxByStatus(status types.CctxStatus) ([]types.CrossChainTx, error) { + client := types.NewQueryClient(b.grpcConn) + resp, err := client.CctxByStatus(context.Background(), &types.QueryCctxByStatusRequest{Status: status}) + if err != nil { + return nil, err + } + return resp.CrossChainTx, nil +} + +func (b *ZetaCoreBridge) GetGenesisSupply() (sdkmath.Int, error) { + tmURL := fmt.Sprintf("http://%s", b.cfg.ChainRPC) + s, err := tmhttp.New(tmURL, "/websocket") + if err != nil { + return sdkmath.ZeroInt(), err + } + res, err := s.Genesis(context.Background()) + if err != nil { + return sdkmath.ZeroInt(), err + } + appState, err := genutiltypes.GenesisStateFromGenDoc(*res.Genesis) + if err != nil { + return sdkmath.ZeroInt(), err + } + bankstate := banktypes.GetGenesisStateFromAppState(b.encodingCfg.Codec, appState) + return bankstate.Supply.AmountOf(config.BaseDenom), nil +} + +func (b *ZetaCoreBridge) GetZetaTokenSupplyOnNode() (sdkmath.Int, error) { + client := banktypes.NewQueryClient(b.grpcConn) + resp, err := client.SupplyOf(context.Background(), &banktypes.QuerySupplyOfRequest{Denom: config.BaseDenom}) + if err != nil { + return sdkmath.ZeroInt(), err + } + return resp.GetAmount().Amount, nil +} + func (b *ZetaCoreBridge) GetLastBlockHeight() ([]*types.LastBlockHeight, error) { client := types.NewQueryClient(b.grpcConn) resp, err := client.LastBlockHeightAll(context.Background(), &types.QueryAllLastBlockHeightRequest{}) diff --git a/zetaclient/supported_chains.go b/zetaclient/supported_chains.go deleted file mode 100644 index 022029667a..0000000000 --- a/zetaclient/supported_chains.go +++ /dev/null @@ -1,10 +0,0 @@ -package zetaclient - -import ( - "github.com/zeta-chain/zetacore/common" -) - -// Modify to update this from the core later -func GetSupportedChains() []*common.Chain { - return common.DefaultChainsList() -} diff --git a/zetaclient/tss_signer.go b/zetaclient/tss_signer.go index 1291a95d15..4013622516 100644 --- a/zetaclient/tss_signer.go +++ b/zetaclient/tss_signer.go @@ -68,6 +68,10 @@ type TSS struct { Signers []string CoreBridge ZetaCoreBridger Metrics *ChainMetrics + + // TODO: support multiple Bitcoin network, not just one network + // https://github.com/zeta-chain/node/issues/1397 + BitcoinChainID int64 } // NewTSS creates a new TSS instance @@ -79,17 +83,19 @@ func NewTSS( bridge ZetaCoreBridger, tssHistoricalList []types.TSS, metrics *metrics.Metrics, + bitcoinChainID int64, ) (*TSS, error) { server, err := SetupTSSServer(peer, privkey, preParams, cfg) if err != nil { return nil, fmt.Errorf("SetupTSSServer error: %w", err) } newTss := TSS{ - Server: server, - Keys: make(map[string]*TSSKey), - CurrentPubkey: cfg.CurrentTssPubkey, - logger: log.With().Str("module", "tss_signer").Logger(), - CoreBridge: bridge, + Server: server, + Keys: make(map[string]*TSSKey), + CurrentPubkey: cfg.CurrentTssPubkey, + logger: log.With().Str("module", "tss_signer").Logger(), + CoreBridge: bridge, + BitcoinChainID: bitcoinChainID, } err = newTss.LoadTssFilesFromDirectory(cfg.TssPath) @@ -175,8 +181,9 @@ func (tss *TSS) Pubkey() []byte { return tss.Keys[tss.CurrentPubkey].PubkeyInBytes } +// Sign signs a digest // digest should be Hashes of some data -// Sign: Specify optionalPubkey to use a different pubkey than the current pubkey set during keygen +// NOTE: Specify optionalPubkey to use a different pubkey than the current pubkey set during keygen func (tss *TSS) Sign(digest []byte, height uint64, nonce uint64, chain *common.Chain, optionalPubKey string) ([65]byte, error) { H := digest log.Debug().Msgf("hash of digest is %s", H) @@ -372,7 +379,7 @@ func (tss *TSS) EVMAddress() ethcommon.Address { // BTCAddress generates a bech32 p2wpkh address from pubkey func (tss *TSS) BTCAddress() string { - addr, err := GetTssAddrBTC(tss.CurrentPubkey) + addr, err := GetTssAddrBTC(tss.CurrentPubkey, tss.BitcoinChainID) if err != nil { log.Error().Err(err).Msg("getKeyAddr error") return "" @@ -381,7 +388,7 @@ func (tss *TSS) BTCAddress() string { } func (tss *TSS) BTCAddressWitnessPubkeyHash() *btcutil.AddressWitnessPubKeyHash { - addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tss.CurrentPubkey) + addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tss.CurrentPubkey, tss.BitcoinChainID) if err != nil { log.Error().Err(err).Msg("BTCAddressPubkeyHash error") return nil @@ -481,9 +488,8 @@ func (tss *TSS) LoadTssFilesFromDirectory(tssPath string) error { return nil } -// FIXME: mainnet/testnet -func GetTssAddrBTC(tssPubkey string) (string, error) { - addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tssPubkey) +func GetTssAddrBTC(tssPubkey string, bitcoinChainID int64) (string, error) { + addrWPKH, err := getKeyAddrBTCWitnessPubkeyHash(tssPubkey, bitcoinChainID) if err != nil { log.Fatal().Err(err) return "", err @@ -590,12 +596,18 @@ func wasNodePartOfTss(granteePubKey32 string, granteeList []string) bool { return false } -func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string) (*btcutil.AddressWitnessPubKeyHash, error) { +func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string, chainID int64) (*btcutil.AddressWitnessPubKeyHash, error) { pubk, err := zcommon.GetPubKeyFromBech32(zcommon.Bech32PubKeyTypeAccPub, tssPubkey) if err != nil { return nil, err } - addr, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(pubk.Bytes()), config.BitconNetParams) + + bitcoinNetParams, err := common.BitcoinNetParamsFromChainID(chainID) + if err != nil { + return nil, err + } + + addr, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(pubk.Bytes()), bitcoinNetParams) if err != nil { return nil, err } diff --git a/zetaclient/tx.go b/zetaclient/tx.go index d5d9c89571..9006e402da 100644 --- a/zetaclient/tx.go +++ b/zetaclient/tx.go @@ -31,8 +31,39 @@ const ( DefaultRetryInterval = 5 ) -func GetInBoundVoteMessage(sender string, senderChain int64, txOrigin string, receiver string, receiverChain int64, amount math.Uint, message string, inTxHash string, inBlockHeight uint64, gasLimit uint64, coinType common.CoinType, asset string, signerAddress string) *types.MsgVoteOnObservedInboundTx { - msg := types.NewMsgVoteOnObservedInboundTx(signerAddress, sender, senderChain, txOrigin, receiver, receiverChain, amount, message, inTxHash, inBlockHeight, gasLimit, coinType, asset) +// GetInBoundVoteMessage returns a new MsgVoteOnObservedInboundTx +func GetInBoundVoteMessage( + sender string, + senderChain int64, + txOrigin string, + receiver string, + receiverChain int64, + amount math.Uint, + message string, + inTxHash string, + inBlockHeight uint64, + gasLimit uint64, + coinType common.CoinType, + asset string, + signerAddress string, + eventIndex uint, +) *types.MsgVoteOnObservedInboundTx { + msg := types.NewMsgVoteOnObservedInboundTx( + signerAddress, + sender, + senderChain, + txOrigin, + receiver, + receiverChain, + amount, + message, + inTxHash, + inBlockHeight, + gasLimit, + coinType, + asset, + eventIndex, + ) return msg } diff --git a/zetaclient/utils.go b/zetaclient/utils.go index 389732f684..1985bad5ba 100644 --- a/zetaclient/utils.go +++ b/zetaclient/utils.go @@ -5,6 +5,7 @@ import ( "context" "encoding/base64" "encoding/hex" + "encoding/json" "fmt" "math" "math/big" @@ -26,8 +27,28 @@ import ( const ( satoshiPerBitcoin = 1e8 + bytesPerKB = 1000 ) +func PrettyPrintStruct(val interface{}) (string, error) { + prettyStruct, err := json.MarshalIndent( + val, + "", + " ", + ) + if err != nil { + return "", err + } + return string(prettyStruct), nil +} + +// feeRateToSatPerByte converts a fee rate in BTC/KB to sat/byte. +func feeRateToSatPerByte(rate float64) *big.Int { + // #nosec G701 always in range + satPerKB := new(big.Int).SetInt64(int64(rate * satoshiPerBitcoin)) + return new(big.Int).Div(satPerKB, big.NewInt(bytesPerKB)) +} + func getSatoshis(btc float64) (int64, error) { // The amount is only considered invalid if it cannot be represented // as an integer type. This may happen if f is NaN or +-Infinity. @@ -66,12 +87,16 @@ type DynamicTicker struct { impl *time.Ticker } -func NewDynamicTicker(name string, interval uint64) *DynamicTicker { +func NewDynamicTicker(name string, interval uint64) (*DynamicTicker, error) { + if interval <= 0 { + return nil, fmt.Errorf("non-positive ticker interval %d for %s", interval, name) + } + return &DynamicTicker{ name: name, interval: interval, impl: time.NewTicker(time.Duration(interval) * time.Second), - } + }, nil } func (t *DynamicTicker) C() <-chan time.Time { @@ -116,7 +141,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForDepositedEvent(event *erc20custody ob.chain.ChainId, "", clienttypes.BytesToEthHex(event.Recipient), - common.ZetaChain().ChainId, + ob.zetaClient.ZetaChain().ChainId, sdkmath.NewUintFromBigInt(event.Amount), hex.EncodeToString(event.Message), event.Raw.TxHash.Hex(), @@ -125,6 +150,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForDepositedEvent(event *erc20custody common.CoinType_ERC20, event.Asset.String(), ob.zetaClient.GetKeys().GetOperatorAddress().String(), + event.Raw.Index, ), nil } @@ -136,7 +162,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForZetaSentEvent(event *zetaconnector return types.MsgVoteOnObservedInboundTx{}, fmt.Errorf("chain id not supported %d", event.DestinationChainId.Int64()) } destAddr := clienttypes.BytesToEthHex(event.DestinationAddress) - if *destChain != common.ZetaChain() { + if !destChain.IsZetaChain() { cfgDest, found := ob.cfg.GetEVMConfig(destChain.ChainId) if !found { return types.MsgVoteOnObservedInboundTx{}, fmt.Errorf("chain id not present in EVMChainConfigs %d", event.DestinationChainId.Int64()) @@ -160,6 +186,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForZetaSentEvent(event *zetaconnector common.CoinType_Zeta, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), + event.Raw.Index, ), nil } @@ -176,7 +203,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForTokenSentToTSS(txhash ethcommon.Ha ob.chain.ChainId, from.Hex(), from.Hex(), - common.ZetaChain().ChainId, + ob.zetaClient.ZetaChain().ChainId, sdkmath.NewUintFromBigInt(value), message, txhash.Hex(), @@ -185,5 +212,6 @@ func (ob *EVMChainClient) GetInboundVoteMsgForTokenSentToTSS(txhash ethcommon.Ha common.CoinType_Gas, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), + 0, // not a smart contract call ) } diff --git a/zetaclient/zeta_supply_checker.go b/zetaclient/zeta_supply_checker.go new file mode 100644 index 0000000000..e24dc28c3f --- /dev/null +++ b/zetaclient/zeta_supply_checker.go @@ -0,0 +1,264 @@ +package zetaclient + +import ( + "fmt" + + sdkmath "cosmossdk.io/math" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/pkg/errors" + "github.com/rs/zerolog" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" + "github.com/zeta-chain/zetacore/zetaclient/config" +) + +type ZetaSupplyChecker struct { + cfg *config.Config + evmClient map[int64]*ethclient.Client + zetaClient *ZetaCoreBridge + ticker *DynamicTicker + stop chan struct{} + logger zerolog.Logger + externalEvmChain []common.Chain + ethereumChain common.Chain + genesisSupply sdkmath.Int +} + +func NewZetaSupplyChecker(cfg *config.Config, zetaClient *ZetaCoreBridge, logger zerolog.Logger) (ZetaSupplyChecker, error) { + dynamicTicker, err := NewDynamicTicker(fmt.Sprintf("ZETASupplyTicker"), 15) + if err != nil { + return ZetaSupplyChecker{}, err + } + + zetaSupplyChecker := ZetaSupplyChecker{ + stop: make(chan struct{}), + ticker: dynamicTicker, + evmClient: make(map[int64]*ethclient.Client), + logger: logger.With(). + Str("module", "ZetaSupplyChecker"). + Logger(), + cfg: cfg, + zetaClient: zetaClient, + } + for _, evmConfig := range cfg.GetAllEVMConfigs() { + if evmConfig.Chain.IsZetaChain() { + continue + } + client, err := ethclient.Dial(evmConfig.Endpoint) + if err != nil { + return zetaSupplyChecker, err + } + zetaSupplyChecker.evmClient[evmConfig.Chain.ChainId] = client + } + + for chainID := range zetaSupplyChecker.evmClient { + chain := common.GetChainFromChainID(chainID) + if chain.IsExternalChain() && common.IsEVMChain(chain.ChainId) && !common.IsEthereumChain(chain.ChainId) { + zetaSupplyChecker.externalEvmChain = append(zetaSupplyChecker.externalEvmChain, *chain) + } + if common.IsEthereumChain(chain.ChainId) { + zetaSupplyChecker.ethereumChain = *chain + } + } + balances, err := zetaSupplyChecker.zetaClient.GetGenesisSupply() + if err != nil { + return zetaSupplyChecker, err + } + tokensMintedAtBeginBlock, ok := sdkmath.NewIntFromString("200000000000000000") + if !ok { + return zetaSupplyChecker, fmt.Errorf("error parsing tokens minted at begin block") + } + zetaSupplyChecker.genesisSupply = balances.Add(tokensMintedAtBeginBlock) + + logger.Info().Msgf("zeta supply checker initialized , external chains : %v ,ethereum chain :%v", zetaSupplyChecker.externalEvmChain, zetaSupplyChecker.ethereumChain) + + return zetaSupplyChecker, nil +} +func (zs *ZetaSupplyChecker) Start() { + defer zs.ticker.Stop() + for { + select { + case <-zs.ticker.C(): + err := zs.CheckZetaTokenSupply() + if err != nil { + zs.logger.Error().Err(err).Msgf("ZetaSupplyChecker error") + } + case <-zs.stop: + return + } + } +} + +func (zs *ZetaSupplyChecker) Stop() { + zs.logger.Info().Msgf("ZetaSupplyChecker is stopping") + close(zs.stop) +} + +func (zs *ZetaSupplyChecker) CheckZetaTokenSupply() error { + + externalChainTotalSupply := sdkmath.ZeroInt() + for _, chain := range zs.externalEvmChain { + externalEvmChainConfig, ok := zs.cfg.GetEVMConfig(chain.ChainId) + if !ok { + return fmt.Errorf("externalEvmChainConfig not found for chain id %d", chain.ChainId) + } + zetaTokenAddressString := externalEvmChainConfig.ZetaTokenContractAddress + zetaTokenAddress := ethcommon.HexToAddress(zetaTokenAddressString) + zetatokenNonEth, err := FetchZetaZetaNonEthTokenContract(zetaTokenAddress, zs.evmClient[chain.ChainId]) + if err != nil { + return err + } + totalSupply, err := zetatokenNonEth.TotalSupply(nil) + if err != nil { + return err + } + totalSupplyInt, ok := sdkmath.NewIntFromString(totalSupply.String()) + if !ok { + zs.logger.Error().Msgf("error parsing total supply for chain %d", chain.ChainId) + continue + } + externalChainTotalSupply = externalChainTotalSupply.Add(totalSupplyInt) + } + + ethConfig, ok := zs.cfg.GetEVMConfig(zs.ethereumChain.ChainId) + if !ok { + return fmt.Errorf("eth config not found for chain id %d", zs.ethereumChain.ChainId) + } + ethConnectorAddressString := ethConfig.ConnectorContractAddress + ethConnectorAddress := ethcommon.HexToAddress(ethConnectorAddressString) + ethConnectorContract, err := FetchConnectorContractEth(ethConnectorAddress, zs.evmClient[zs.ethereumChain.ChainId]) + if err != nil { + return err + } + + ethLockedAmount, err := ethConnectorContract.GetLockedAmount(nil) + if err != nil { + return err + } + ethLockedAmountInt, ok := sdkmath.NewIntFromString(ethLockedAmount.String()) + if !ok { + return fmt.Errorf("error parsing eth locked amount") + } + + zetaInTransit := zs.GetAmountOfZetaInTransit() + zetaTokenSupplyOnNode, err := zs.zetaClient.GetZetaTokenSupplyOnNode() + if err != nil { + return err + } + abortedAmount, err := zs.AbortedTxAmount() + if err != nil { + return err + } + ValidateZetaSupply(zs.logger, abortedAmount, zetaInTransit, zs.genesisSupply, externalChainTotalSupply, zetaTokenSupplyOnNode, ethLockedAmountInt) + return nil +} + +type ZetaSupplyCheckLogs struct { + Logger zerolog.Logger + AbortedTxAmounts sdkmath.Int `json:"aborted_tx_amounts"` + ZetaInTransit sdkmath.Int `json:"zeta_in_transit"` + ExternalChainTotalSupply sdkmath.Int `json:"external_chain_total_supply"` + ZetaTokenSupplyOnNode sdkmath.Int `json:"zeta_token_supply_on_node"` + EthLockedAmount sdkmath.Int `json:"eth_locked_amount"` + NodeAmounts sdkmath.Int `json:"node_amounts"` + LHS sdkmath.Int `json:"LHS"` + RHS sdkmath.Int `json:"RHS"` + SupplyCheckSuccess bool `json:"supply_check_success"` +} + +func (z ZetaSupplyCheckLogs) LogOutput() { + output, err := PrettyPrintStruct(z) + if err != nil { + z.Logger.Error().Err(err).Msgf("error pretty printing struct") + } + z.Logger.Info().Msgf(output) +} + +func ValidateZetaSupply(logger zerolog.Logger, abortedTxAmounts, zetaInTransit, genesisAmounts, externalChainTotalSupply, zetaTokenSupplyOnNode, ethLockedAmount sdkmath.Int) bool { + lhs := ethLockedAmount.Sub(abortedTxAmounts) + rhs := zetaTokenSupplyOnNode.Add(zetaInTransit).Add(externalChainTotalSupply).Sub(genesisAmounts) + + copyZetaTokenSupplyOnNode := zetaTokenSupplyOnNode + copyGenesisAmounts := genesisAmounts + nodeAmounts := copyZetaTokenSupplyOnNode.Sub(copyGenesisAmounts) + logs := ZetaSupplyCheckLogs{ + Logger: logger, + AbortedTxAmounts: abortedTxAmounts, + ZetaInTransit: zetaInTransit, + ExternalChainTotalSupply: externalChainTotalSupply, + NodeAmounts: nodeAmounts, + ZetaTokenSupplyOnNode: zetaTokenSupplyOnNode, + EthLockedAmount: ethLockedAmount, + LHS: lhs, + RHS: rhs, + } + defer logs.LogOutput() + if !lhs.Equal(rhs) { + logs.SupplyCheckSuccess = false + return false + } + logs.SupplyCheckSuccess = true + return true +} + +func (zs *ZetaSupplyChecker) AbortedTxAmount() (sdkmath.Int, error) { + cctxList, err := zs.zetaClient.GetCctxByStatus(types.CctxStatus_Aborted) + if err != nil { + return sdkmath.ZeroInt(), err + } + amount := sdkmath.ZeroUint() + for _, cctx := range cctxList { + amount = amount.Add(cctx.GetCurrentOutTxParam().Amount) + } + amountInt, ok := sdkmath.NewIntFromString(amount.String()) + if !ok { + return sdkmath.ZeroInt(), errors.New("error parsing amount") + } + return amountInt, nil +} + +func (zs *ZetaSupplyChecker) GetAmountOfZetaInTransit() sdkmath.Int { + chainsToCheck := make([]common.Chain, len(zs.externalEvmChain)+1) + chainsToCheck = append(append(chainsToCheck, zs.externalEvmChain...), zs.ethereumChain) + cctxs := zs.GetPendingCCTXInTransit(chainsToCheck) + amount := sdkmath.ZeroUint() + for _, cctx := range cctxs { + amount = amount.Add(cctx.GetCurrentOutTxParam().Amount) + } + amountInt, ok := sdkmath.NewIntFromString(amount.String()) + if !ok { + panic("error parsing amount") + } + return amountInt +} +func (zs *ZetaSupplyChecker) GetPendingCCTXInTransit(receivingChains []common.Chain) []*types.CrossChainTx { + cctxInTransit := make([]*types.CrossChainTx, 0) + for _, chain := range receivingChains { + cctx, err := zs.zetaClient.GetAllPendingCctx(chain.ChainId) + if err != nil { + continue + } + nonceToCctxMap := make(map[uint64]*types.CrossChainTx) + for _, c := range cctx { + if c.GetInboundTxParams().CoinType == common.CoinType_Zeta { + nonceToCctxMap[c.GetCurrentOutTxParam().OutboundTxTssNonce] = c + } + } + + trackers, err := zs.zetaClient.GetAllOutTxTrackerByChain(chain, Ascending) + if err != nil { + continue + } + for _, tracker := range trackers { + zs.logger.Info().Msgf("tracker exists for nonce: %d , removing from supply checks", tracker.Nonce) + delete(nonceToCctxMap, tracker.Nonce) + } + for _, c := range nonceToCctxMap { + if c != nil { + cctxInTransit = append(cctxInTransit, c) + } + } + } + return cctxInTransit +} diff --git a/zetaclient/zeta_supply_checker_test.go b/zetaclient/zeta_supply_checker_test.go new file mode 100644 index 0000000000..020477ccd4 --- /dev/null +++ b/zetaclient/zeta_supply_checker_test.go @@ -0,0 +1,53 @@ +package zetaclient_test + +import ( + "os" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/rs/zerolog" + "github.com/stretchr/testify/assert" + "github.com/zeta-chain/zetacore/zetaclient" +) + +func MustNewIntFromString(val string) sdkmath.Int { + v, ok := sdkmath.NewIntFromString(val) + if !ok { + panic("invalid int") + } + return v +} +func TestZetaSupplyChecker_ValidateZetaSupply(t *testing.T) { + tt := []struct { + name string + abortedTxAmount sdkmath.Int + zetaInTransit sdkmath.Int + genesisAmounts sdkmath.Int + externalChainTotalSupply sdkmath.Int + zetaTokenSupplyOnNode sdkmath.Int + ethLockedAmount sdkmath.Int + validate assert.BoolAssertionFunc + }{ + { + name: "1 zeta cctx in progress", + abortedTxAmount: MustNewIntFromString("0"), + zetaInTransit: MustNewIntFromString("1000000000000000000"), + externalChainTotalSupply: MustNewIntFromString("9000000000000000000"), + genesisAmounts: MustNewIntFromString("1000000000000000000"), + zetaTokenSupplyOnNode: MustNewIntFromString("1000000000000000000"), + ethLockedAmount: MustNewIntFromString("10000000000000000000"), + validate: func(t assert.TestingT, b bool, i ...interface{}) bool { + return assert.True(t, b, i...) + }, + }, + // Todo add more scenarios + //https://github.com/zeta-chain/node/issues/1375 + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + logger := zerolog.New(os.Stdout).With().Timestamp().Logger() + tc.validate(t, zetaclient.ValidateZetaSupply(logger, tc.abortedTxAmount, tc.zetaInTransit, tc.genesisAmounts, tc.externalChainTotalSupply, tc.zetaTokenSupplyOnNode, tc.ethLockedAmount)) + }) + } +} diff --git a/zetaclient/zetacore_bridge.go b/zetaclient/zetacore_bridge.go index 682ff6a633..f0cc9483a5 100644 --- a/zetaclient/zetacore_bridge.go +++ b/zetaclient/zetacore_bridge.go @@ -36,13 +36,14 @@ type ZetaCoreBridge struct { keys *Keys broadcastLock *sync.RWMutex zetaChainID string + zetaChain common.Chain lastOutTxReportTime map[string]time.Time stop chan struct{} pause chan struct{} } // NewZetaCoreBridge create a new instance of ZetaCoreBridge -func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID string) (*ZetaCoreBridge, error) { +func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID string, hsmMode bool) (*ZetaCoreBridge, error) { // main module logger logger := log.With().Str("module", "CoreBridge").Logger() cfg := config.ClientConfiguration{ @@ -50,6 +51,7 @@ func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID strin SignerName: signerName, SignerPasswd: "password", ChainRPC: fmt.Sprintf("%s:26657", chainIP), + HsmMode: hsmMode, } httpClient := retryablehttp.NewClient() @@ -70,6 +72,11 @@ func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID strin seqMap[keyType] = 0 } + zetaChain, err := common.ZetaChainFromChainID(chainID) + if err != nil { + return nil, fmt.Errorf("invalid chain id %s, %w", chainID, err) + } + return &ZetaCoreBridge{ logger: logger, grpcConn: grpcConn, @@ -83,6 +90,7 @@ func NewZetaCoreBridge(k *Keys, chainIP string, signerName string, chainID strin lastOutTxReportTime: map[string]time.Time{}, stop: make(chan struct{}), zetaChainID: chainID, + zetaChain: zetaChain, pause: make(chan struct{}), }, nil } @@ -101,10 +109,23 @@ func (b *ZetaCoreBridge) GetLogger() *zerolog.Logger { return &b.logger } -func (b *ZetaCoreBridge) UpdateChainID(chainID string) { +func (b *ZetaCoreBridge) UpdateChainID(chainID string) error { if b.zetaChainID != chainID { b.zetaChainID = chainID + + zetaChain, err := common.ZetaChainFromChainID(chainID) + if err != nil { + return fmt.Errorf("invalid chain id %s, %w", chainID, err) + } + b.zetaChain = zetaChain } + + return nil +} + +// ZetaChain returns the ZetaChain chain object +func (b *ZetaCoreBridge) ZetaChain() common.Chain { + return b.zetaChain } func (b *ZetaCoreBridge) Stop() { diff --git a/zetaclient/zetacore_observer.go b/zetaclient/zetacore_observer.go index fb208dd98d..4317774a60 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -135,7 +135,7 @@ func (co *CoreObserver) startSendScheduler() { supportedChains := co.Config().GetEnabledChains() for _, c := range supportedChains { - if c.ChainId == common.ZetaChain().ChainId { + if c.ChainId == co.bridge.ZetaChain().ChainId { continue } signer := co.signerMap[c]