From 3b54ed61102b10835fa65764a89d57db22a1f8c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:41:57 +0100 Subject: [PATCH 01/41] chore(deps): bump github.com/cosmos/cosmos-db from 1.1.0 to 1.1.1 (#7747) * chore(deps): bump github.com/cosmos/cosmos-db from 1.1.0 to 1.1.1 Bumps [github.com/cosmos/cosmos-db](https://github.com/cosmos/cosmos-db) from 1.1.0 to 1.1.1. - [Changelog](https://github.com/cosmos/cosmos-db/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-db/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/cosmos/cosmos-db dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: tidy all --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Damian Nolan --- e2e/go.mod | 2 +- e2e/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- modules/apps/callbacks/go.mod | 2 +- modules/apps/callbacks/go.sum | 4 ++-- modules/light-clients/08-wasm/go.mod | 2 +- modules/light-clients/08-wasm/go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index 05551038941..0b0135bee43 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -68,7 +68,7 @@ require ( github.com/cometbft/cometbft-db v1.0.1 // indirect github.com/cometbft/cometbft/api v1.0.0 github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-db v1.1.0 // indirect + github.com/cosmos/cosmos-db v1.1.1 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 7ce5e404548..949ad7ea263 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -393,8 +393,8 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= -github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNCM= +github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/cosmos-sdk v0.52.0-beta.2.0.20241213155709-f1e881e81b1b h1:ZaEAV5tsUTnyWEC/Gt8DXHKBANDyx70PVCiPOEVnuHk= diff --git a/go.mod b/go.mod index b483947bef6..5b6f66aa223 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v1.0.0 github.com/cometbft/cometbft/api v1.0.0 - github.com/cosmos/cosmos-db v1.1.0 + github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.7.0 diff --git a/go.sum b/go.sum index 1fbfc699adc..9c056163ade 100644 --- a/go.sum +++ b/go.sum @@ -373,8 +373,8 @@ github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1A github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= -github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNCM= +github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/cosmos-sdk v0.52.0-beta.2.0.20241213155709-f1e881e81b1b h1:ZaEAV5tsUTnyWEC/Gt8DXHKBANDyx70PVCiPOEVnuHk= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 54ffced3fe7..6b680c892b6 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -31,7 +31,7 @@ require ( cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v1.0.0 github.com/cometbft/cometbft/api v1.0.0 - github.com/cosmos/cosmos-db v1.1.0 + github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/v9 v9.0.0 diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 6dfa6a18b81..3b042abfe3e 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -373,8 +373,8 @@ github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1A github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= -github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNCM= +github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/cosmos-sdk v0.52.0-beta.2.0.20241213155709-f1e881e81b1b h1:ZaEAV5tsUTnyWEC/Gt8DXHKBANDyx70PVCiPOEVnuHk= diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 1e4bfe8788f..af4d570ed2e 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -37,7 +37,7 @@ require ( github.com/CosmWasm/wasmvm/v2 v2.1.2 github.com/cometbft/cometbft v1.0.0 github.com/cometbft/cometbft/api v1.0.0 - github.com/cosmos/cosmos-db v1.1.0 + github.com/cosmos/cosmos-db v1.1.1 github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/v9 v9.0.0 diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 93393de0e78..c2cee7e2e22 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -381,8 +381,8 @@ github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1A github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= -github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNCM= +github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/cosmos-sdk v0.52.0-beta.2.0.20241213155709-f1e881e81b1b h1:ZaEAV5tsUTnyWEC/Gt8DXHKBANDyx70PVCiPOEVnuHk= diff --git a/simapp/go.mod b/simapp/go.mod index b92e6274f48..889b66a215a 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -87,7 +87,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v1.0.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-db v1.1.0 // indirect + github.com/cosmos/cosmos-db v1.1.1 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 6a2594be352..af73195c032 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -379,8 +379,8 @@ github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1A github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= -github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNCM= +github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/cosmos-sdk v0.52.0-beta.2.0.20241213155709-f1e881e81b1b h1:ZaEAV5tsUTnyWEC/Gt8DXHKBANDyx70PVCiPOEVnuHk= From d078d3f766cd1b85ff2ec3f49dccf800bc2dc7c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:09:10 +0100 Subject: [PATCH 02/41] chore(deps): bump cosmossdk.io/x/accounts/defaults/base from 0.0.0-20241218104812-cb56c6e47f76 to 0.2.0-rc.1 (#7745) * chore(deps): bump cosmossdk.io/x/accounts/defaults/base Bumps [cosmossdk.io/x/accounts/defaults/base](https://github.com/cosmos/cosmos-sdk) from 0.0.0-20241218104812-cb56c6e47f76 to 0.2.0-rc.1. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/commits/x/nft/v0.2.0-rc.1) --- updated-dependencies: - dependency-name: cosmossdk.io/x/accounts/defaults/base dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore: tidy all - bumps go version * chore: update go version in dockerfiles --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Damian Nolan --- Dockerfile | 2 +- e2e/go.mod | 12 ++++++------ e2e/go.sum | 4 ++-- go.mod | 12 ++++++------ go.sum | 4 ++-- modules/apps/callbacks/go.mod | 12 ++++++------ modules/apps/callbacks/go.sum | 4 ++-- modules/light-clients/08-wasm/Dockerfile | 2 +- modules/light-clients/08-wasm/go.mod | 12 ++++++------ modules/light-clients/08-wasm/go.sum | 4 ++-- simapp/go.mod | 12 ++++++------ simapp/go.sum | 4 ++-- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1717bc183c8..9c66ac32456 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.3-alpine as builder +FROM golang:1.23.4-alpine as builder ARG IBC_GO_VERSION RUN set -eux; apk add --no-cache gcc git libusb-dev linux-headers make musl-dev; diff --git a/e2e/go.mod b/e2e/go.mod index 0b0135bee43..d0528efd818 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/ibc-go/e2e -go 1.23.3 +go 1.23.4 // needed temporarily for v9. replace ( @@ -36,15 +36,15 @@ require ( cosmossdk.io/depinject v1.1.0 // indirect cosmossdk.io/log v1.5.0 // indirect cosmossdk.io/schema v1.0.0 // indirect - cosmossdk.io/store v1.10.0-rc.1 // indirect + cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 // indirect cosmossdk.io/x/authz v0.0.0-20241108061010-a0458127fccf - cosmossdk.io/x/bank v0.0.0-20241108061010-a0458127fccf + cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/distribution v0.0.0-20241108061010-a0458127fccf // indirect cosmossdk.io/x/feegrant v0.1.1 // indirect cosmossdk.io/x/gov v0.0.0-20241108061010-a0458127fccf cosmossdk.io/x/params v0.0.0-20241108061010-a0458127fccf cosmossdk.io/x/slashing v0.0.0-20241108061010-a0458127fccf // indirect - cosmossdk.io/x/staking v0.0.0-20241108061010-a0458127fccf // indirect + cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d // indirect cosmossdk.io/x/tx v1.0.0-alpha.3 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -223,8 +223,8 @@ require ( cloud.google.com/go/storage v1.43.0 // indirect cosmossdk.io/client/v2 v2.0.0-beta.6 // indirect cosmossdk.io/core/testing v0.0.1 // indirect - cosmossdk.io/x/accounts v0.0.0-20240913065641-0064ccbce64e // indirect - cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 // indirect + cosmossdk.io/x/accounts v0.0.0-20241218110910-47409028a73d // indirect + cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 // indirect cosmossdk.io/x/accounts/defaults/lockup v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/consensus v0.0.0-20241108061010-a0458127fccf // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 949ad7ea263..d9a2920d1fb 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -216,8 +216,8 @@ cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608 h1:NaFVgzmO3YFX+l76 cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608/go.mod h1:eZNgZKvZRlDUk8CE3LTDVMAcSM7zLOet2S8fByQkF3s= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608 h1:No84LXBp0kEzJfAqorxrgqzmzqOpHhbs8IK2nBpVQJY= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608/go.mod h1:wADXnci9qeFwOQ09qiyf1uLdI4n/RSSTG8mSM9hmxys= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 h1:g2Nby5rzo9dCaX9/XC4i+f5EsXNbr89ItxnrHeKS8Vk= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76/go.mod h1:/yzjhfOOxcbhrYxQfTHyxNMzGhemHH4mg8k0o54UI4M= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 h1:sVAOVQLbdmzLmjnWLhAhIN65HTmSMGBIwU2uTeSCEp0= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1/go.mod h1:52PyilJMRraVwNcG58q4t7OSzSHApqNfJheq+mNB+qw= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608 h1:nMu0DD9qutZ7dzIySxTRnLYvZtockBghVkwBHyuwBLI= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608/go.mod h1:m0eg/A4J5fmXFNGEldQpeTrMr9PFWaVIFjbDYes0j9I= cosmossdk.io/x/accounts/defaults/multisig v0.0.0-20241213081318-957e24171608 h1:JL+VXHmb8xqwU7ToR2RG0V2BTmE+t1PkJ880xKi46Tc= diff --git a/go.mod b/go.mod index 5b6f66aa223..5406b125485 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -go 1.23.3 +go 1.23.4 module github.com/cosmos/ibc-go/v9 @@ -9,13 +9,13 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.4.0 - cosmossdk.io/store v1.10.0-rc.1 - cosmossdk.io/x/accounts v0.0.0-20240913065641-0064ccbce64e - cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 + cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 + cosmossdk.io/x/accounts v0.0.0-20241218110910-47409028a73d + cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 cosmossdk.io/x/accounts/defaults/lockup v0.0.0-00010101000000-000000000000 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 + cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 cosmossdk.io/x/distribution v0.0.0-20240906090851-36d9b25e8981 cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 @@ -28,7 +28,7 @@ require ( cosmossdk.io/x/params v0.0.0-00010101000000-000000000000 cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 + cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/tx v1.0.0-alpha.3 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v1.0.0 diff --git a/go.sum b/go.sum index 9c056163ade..957f3dc8c81 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608 h1:NaFVgzmO3YFX+l76 cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608/go.mod h1:eZNgZKvZRlDUk8CE3LTDVMAcSM7zLOet2S8fByQkF3s= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608 h1:No84LXBp0kEzJfAqorxrgqzmzqOpHhbs8IK2nBpVQJY= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608/go.mod h1:wADXnci9qeFwOQ09qiyf1uLdI4n/RSSTG8mSM9hmxys= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 h1:g2Nby5rzo9dCaX9/XC4i+f5EsXNbr89ItxnrHeKS8Vk= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76/go.mod h1:/yzjhfOOxcbhrYxQfTHyxNMzGhemHH4mg8k0o54UI4M= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 h1:sVAOVQLbdmzLmjnWLhAhIN65HTmSMGBIwU2uTeSCEp0= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1/go.mod h1:52PyilJMRraVwNcG58q4t7OSzSHApqNfJheq+mNB+qw= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608 h1:nMu0DD9qutZ7dzIySxTRnLYvZtockBghVkwBHyuwBLI= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608/go.mod h1:m0eg/A4J5fmXFNGEldQpeTrMr9PFWaVIFjbDYes0j9I= cosmossdk.io/x/accounts/defaults/multisig v0.0.0-20241213081318-957e24171608 h1:JL+VXHmb8xqwU7ToR2RG0V2BTmE+t1PkJ880xKi46Tc= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 6b680c892b6..a0abce18ca1 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/ibc-go/modules/apps/callbacks -go 1.23.3 +go 1.23.4 replace github.com/cosmos/ibc-go/v9 => ../../../ @@ -12,12 +12,12 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.4.0 - cosmossdk.io/store v1.10.0-rc.1 - cosmossdk.io/x/accounts v0.0.0-20240913065641-0064ccbce64e - cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 + cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 + cosmossdk.io/x/accounts v0.0.0-20241218110910-47409028a73d + cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20240417181816-5e7aae0db1f5 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 + cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 cosmossdk.io/x/distribution v0.0.0-20240906090851-36d9b25e8981 cosmossdk.io/x/feegrant v0.1.1 @@ -26,7 +26,7 @@ require ( cosmossdk.io/x/params v0.0.0-00010101000000-000000000000 cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 + cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/tx v1.0.0-alpha.3 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v1.0.0 diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 3b042abfe3e..742ddc78936 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -216,8 +216,8 @@ cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608 h1:NaFVgzmO3YFX+l76 cosmossdk.io/store v1.0.0-rc.0.0.20241213081318-957e24171608/go.mod h1:eZNgZKvZRlDUk8CE3LTDVMAcSM7zLOet2S8fByQkF3s= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608 h1:No84LXBp0kEzJfAqorxrgqzmzqOpHhbs8IK2nBpVQJY= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608/go.mod h1:wADXnci9qeFwOQ09qiyf1uLdI4n/RSSTG8mSM9hmxys= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 h1:g2Nby5rzo9dCaX9/XC4i+f5EsXNbr89ItxnrHeKS8Vk= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76/go.mod h1:/yzjhfOOxcbhrYxQfTHyxNMzGhemHH4mg8k0o54UI4M= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 h1:sVAOVQLbdmzLmjnWLhAhIN65HTmSMGBIwU2uTeSCEp0= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1/go.mod h1:52PyilJMRraVwNcG58q4t7OSzSHApqNfJheq+mNB+qw= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608 h1:nMu0DD9qutZ7dzIySxTRnLYvZtockBghVkwBHyuwBLI= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608/go.mod h1:m0eg/A4J5fmXFNGEldQpeTrMr9PFWaVIFjbDYes0j9I= cosmossdk.io/x/accounts/defaults/multisig v0.0.0-20241213081318-957e24171608 h1:JL+VXHmb8xqwU7ToR2RG0V2BTmE+t1PkJ880xKi46Tc= diff --git a/modules/light-clients/08-wasm/Dockerfile b/modules/light-clients/08-wasm/Dockerfile index 9a4b9985a66..27d5f84b79d 100644 --- a/modules/light-clients/08-wasm/Dockerfile +++ b/modules/light-clients/08-wasm/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.3-alpine as builder +FROM golang:1.23.4-alpine as builder ARG LIBWASM_VERSION ARG LIBWASM_CHECKSUM diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index af4d570ed2e..c86523dbcc4 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/ibc-go/modules/light-clients/08-wasm -go 1.23.3 +go 1.23.4 require ( cosmossdk.io/api v0.8.0 @@ -10,14 +10,14 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.5.0 cosmossdk.io/math v1.4.0 - cosmossdk.io/store v1.10.0-rc.1 + cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 cosmossdk.io/tools/confix v0.1.2 - cosmossdk.io/x/accounts v0.0.0-20240913065641-0064ccbce64e - cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 + cosmossdk.io/x/accounts v0.0.0-20241218110910-47409028a73d + cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 cosmossdk.io/x/accounts/defaults/lockup v0.0.0-00010101000000-000000000000 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 + cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 cosmossdk.io/x/distribution v0.0.0-20240906090851-36d9b25e8981 @@ -31,7 +31,7 @@ require ( cosmossdk.io/x/params v0.0.0-00010101000000-000000000000 cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 + cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/tx v1.0.0-alpha.3 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmvm/v2 v2.1.2 diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index c2cee7e2e22..d74a0aba443 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -218,8 +218,8 @@ cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4= cosmossdk.io/tools/confix v0.1.2/go.mod h1:7XfcbK9sC/KNgVGxgLM0BrFbVcR/+6Dg7MFfpx7duYo= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608 h1:No84LXBp0kEzJfAqorxrgqzmzqOpHhbs8IK2nBpVQJY= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608/go.mod h1:wADXnci9qeFwOQ09qiyf1uLdI4n/RSSTG8mSM9hmxys= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 h1:g2Nby5rzo9dCaX9/XC4i+f5EsXNbr89ItxnrHeKS8Vk= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76/go.mod h1:/yzjhfOOxcbhrYxQfTHyxNMzGhemHH4mg8k0o54UI4M= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 h1:sVAOVQLbdmzLmjnWLhAhIN65HTmSMGBIwU2uTeSCEp0= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1/go.mod h1:52PyilJMRraVwNcG58q4t7OSzSHApqNfJheq+mNB+qw= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608 h1:nMu0DD9qutZ7dzIySxTRnLYvZtockBghVkwBHyuwBLI= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608/go.mod h1:m0eg/A4J5fmXFNGEldQpeTrMr9PFWaVIFjbDYes0j9I= cosmossdk.io/x/accounts/defaults/multisig v0.0.0-20241213081318-957e24171608 h1:JL+VXHmb8xqwU7ToR2RG0V2BTmE+t1PkJ880xKi46Tc= diff --git a/simapp/go.mod b/simapp/go.mod index 889b66a215a..444d5c74042 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -1,4 +1,4 @@ -go 1.23.3 +go 1.23.4 module github.com/cosmos/ibc-go/simapp @@ -11,14 +11,14 @@ require ( cosmossdk.io/core v1.0.0 cosmossdk.io/core/testing v0.0.1 cosmossdk.io/log v1.5.0 - cosmossdk.io/store v1.10.0-rc.1 + cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43 cosmossdk.io/tools/confix v0.1.2 - cosmossdk.io/x/accounts v0.0.0-20240913065641-0064ccbce64e - cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 + cosmossdk.io/x/accounts v0.0.0-20241218110910-47409028a73d + cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 cosmossdk.io/x/accounts/defaults/lockup v0.0.0-00010101000000-000000000000 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 + cosmossdk.io/x/bank v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/consensus v0.0.0-20240911130545-9e7848985491 cosmossdk.io/x/distribution v0.0.0-20240906090851-36d9b25e8981 @@ -32,7 +32,7 @@ require ( cosmossdk.io/x/params v0.0.0-00010101000000-000000000000 cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 + cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/tx v1.0.0-alpha.3 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v1.0.0 diff --git a/simapp/go.sum b/simapp/go.sum index af73195c032..88881b083e3 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -218,8 +218,8 @@ cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4= cosmossdk.io/tools/confix v0.1.2/go.mod h1:7XfcbK9sC/KNgVGxgLM0BrFbVcR/+6Dg7MFfpx7duYo= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608 h1:No84LXBp0kEzJfAqorxrgqzmzqOpHhbs8IK2nBpVQJY= cosmossdk.io/x/accounts v0.0.0-20241213081318-957e24171608/go.mod h1:wADXnci9qeFwOQ09qiyf1uLdI4n/RSSTG8mSM9hmxys= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76 h1:g2Nby5rzo9dCaX9/XC4i+f5EsXNbr89ItxnrHeKS8Vk= -cosmossdk.io/x/accounts/defaults/base v0.0.0-20241218104812-cb56c6e47f76/go.mod h1:/yzjhfOOxcbhrYxQfTHyxNMzGhemHH4mg8k0o54UI4M= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1 h1:sVAOVQLbdmzLmjnWLhAhIN65HTmSMGBIwU2uTeSCEp0= +cosmossdk.io/x/accounts/defaults/base v0.2.0-rc.1/go.mod h1:52PyilJMRraVwNcG58q4t7OSzSHApqNfJheq+mNB+qw= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608 h1:nMu0DD9qutZ7dzIySxTRnLYvZtockBghVkwBHyuwBLI= cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20241213081318-957e24171608/go.mod h1:m0eg/A4J5fmXFNGEldQpeTrMr9PFWaVIFjbDYes0j9I= cosmossdk.io/x/accounts/defaults/multisig v0.0.0-20241213081318-957e24171608 h1:JL+VXHmb8xqwU7ToR2RG0V2BTmE+t1PkJ880xKi46Tc= From c5ec835658680aaee5f50d9221e0c6fb98e2d67f Mon Sep 17 00:00:00 2001 From: iIvaki Date: Thu, 19 Dec 2024 19:35:52 +0200 Subject: [PATCH 03/41] fixed exp error in modules/04-channel/types/packet-test.go (#7749) * fixed exp error in modules/04-channel/types/packet-test.go * chore * move to top --------- Co-authored-by: Damian Nolan --- modules/core/04-channel/types/packet_test.go | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index fca1d9a357d..599bd623a51 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "testing" "github.com/stretchr/testify/require" @@ -55,28 +56,27 @@ func TestCommitPacket(t *testing.T) { func TestPacketValidateBasic(t *testing.T) { testCases := []struct { - packet types.Packet - expPass bool - errMsg string + packet types.Packet + expError error }{ - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, - {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"}, - {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"}, - {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), false, "disabled both timeout height and timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), true, "disabled timeout timestamp, valid timeout height"}, - {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), nil}, + {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("packet sequence cannot be 0: invalid packet")}, + {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid source port")}, + {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid source channel")}, + {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid destination port")}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), errors.New("invalid destination channel")}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), errors.New("packet timeout height and packet timeout timestamp cannot both be 0: invalid packet")}, } - for i, tc := range testCases { + for _, tc := range testCases { err := tc.packet.ValidateBasic() - if tc.expPass { - require.NoError(t, err, "Msg %d failed: %s", i, tc.errMsg) + if tc.expError == nil { + require.NoError(t, err) } else { - require.Error(t, err, "Invalid Msg %d passed: %s", i, tc.errMsg) + require.ErrorContains(t, err, tc.expError.Error()) } } } From a6ee2282b8de9cd99aada0457fc4ff49a27cb9b7 Mon Sep 17 00:00:00 2001 From: iIvaki Date: Thu, 19 Dec 2024 19:46:42 +0200 Subject: [PATCH 04/41] fixed exp error in modules/02-client/types/client-test.go (#7741) Co-authored-by: Damian Nolan --- modules/core/02-client/types/client_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 43b5b1c7f58..6655c04c6e3 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "testing" "github.com/stretchr/testify/require" @@ -63,15 +64,15 @@ func TestValidateClientType(t *testing.T) { testCases := []struct { name string clientType string - expPass bool + expError error }{ - {"valid", "tendermint", true}, - {"valid solomachine", "solomachine-v1", true}, - {"too large", "tenderminttenderminttenderminttenderminttendermintt", false}, - {"too short", "t", false}, - {"blank id", " ", false}, - {"empty id", "", false}, - {"ends with dash", "tendermint-", false}, + {"valid", "tendermint", nil}, + {"valid solomachine", "solomachine-v1", nil}, + {"too large", "tenderminttenderminttenderminttenderminttendermintt", errors.New("client type results in largest client identifier being invalid")}, + {"too short", "t", errors.New("client type results in smallest client identifier being invalid")}, + {"blank id", " ", errors.New("client type cannot be blank")}, + {"empty id", "", errors.New("client type cannot be blank")}, + {"ends with dash", "tendermint-", errors.New("invalid client type")}, } for _, tc := range testCases { @@ -79,10 +80,10 @@ func TestValidateClientType(t *testing.T) { err := types.ValidateClientType(tc.clientType) - if tc.expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { - require.Error(t, err, tc.name) + require.ErrorContains(t, err, tc.expError.Error()) } } } From 8164b078e193ddb360a67f990dc08994f4e3363b Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 19 Dec 2024 18:54:16 +0100 Subject: [PATCH 05/41] chore: add backport tasks for new release branches (#7748) --- .github/mergify.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/mergify.yml b/.github/mergify.yml index 55f367b0b62..5255132e514 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -46,6 +46,14 @@ pull_request_rules: backport: branches: - 08-wasm/release/v0.3.x+ibc-go-v7.4.x-wasmvm-v1.5.x + - name: backport patches to v0.4.x wasm ibc-go v7.4.x & wasmvm 1.5.x branch + conditions: + - base=main + - label=backport-wasm-v0.4.x+ibc-go-v7.4.x-wasmvm-v1.5.x + actions: + backport: + branches: + - 08-wasm/release/v0.4.x+ibc-go-v7.4.x-wasmvm-v1.5.x - name: backport patches to v0.4.x wasm ibc-go v8.4.x & wasmvm 2.0.x branch conditions: - base=main @@ -54,6 +62,14 @@ pull_request_rules: backport: branches: - 08-wasm/release/v0.4.x+ibc-go-v8.4.x-wasmvm-v2.0.x + - name: backport patches to v0.5.x wasm ibc-go v8.4.x & wasmvm 2.1.x branch + conditions: + - base=main + - label=backport-wasm-v0.5.x+ibc-go-v8.4.x-wasmvm-v2.1.x + actions: + backport: + branches: + - 08-wasm/release/v0.5.x+ibc-go-v8.4.x-wasmvm-v2.0.x - name: backport patches to v0.5.x wasm ibc-go v9.0.x & wasmvm 2.1.x branch conditions: - base=main From 5bd6eda2b020d9f136b986d4d3e15b013d275463 Mon Sep 17 00:00:00 2001 From: meoaka3 Date: Fri, 20 Dec 2024 00:55:06 +0700 Subject: [PATCH 06/41] fix test TestValidateControllerGenesisState (#7753) Co-authored-by: Damian Nolan --- .../genesis/types/genesis_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index da06cd44b12..6fddd5c8a1b 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -91,12 +91,12 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", func() {}, - true, + nil, }, { "failed to validate active channel - invalid port identifier", @@ -110,7 +110,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate active channel - invalid channel identifier", @@ -124,7 +124,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid port identifier", @@ -145,7 +145,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid owner address", @@ -166,7 +166,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, - false, + icatypes.ErrInvalidAccountAddress, }, { "failed to validate controller ports - invalid port identifier", @@ -187,7 +187,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, } @@ -201,10 +201,11 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { err := genesisState.Validate() - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) + suite.Require().ErrorIs(err, tc.expErr) } }) } From c41f3ef6bf4cc527e652b0dcffa0c16e2fe607c9 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Thu, 19 Dec 2024 20:13:10 +0100 Subject: [PATCH 07/41] chore: added changelog entry for vesting account balance transfer (#7755) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf059d539a5..83678bdf5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (apps/transfer) [\#7650](https://github.com/cosmos/ibc-go/pull/7650) Add support for transfer of entire balance for vesting accounts + ### Bug Fixes * (apps/27-interchain-accounts) [\#7277](https://github.com/cosmos/ibc-go/pull/7277) Use `GogoResolver` when populating module query safe allow list to avoid panics from unresolvable protobuf dependencies. From f5e1a4c33c01d355323ea368d8d63664180736e5 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 20 Dec 2024 09:41:34 +0100 Subject: [PATCH 08/41] refactor: ibc core runtime env (#7601) --- modules/apps/callbacks/testing/simapp/app.go | 6 +- modules/core/02-client/abci.go | 12 +- modules/core/02-client/keeper/client.go | 42 +- modules/core/02-client/keeper/events.go | 189 ++--- modules/core/02-client/keeper/grpc_query.go | 17 +- modules/core/02-client/keeper/keeper.go | 47 +- modules/core/02-client/keeper/migrations.go | 4 +- modules/core/03-connection/keeper/events.go | 120 +-- .../core/03-connection/keeper/grpc_query.go | 25 +- .../core/03-connection/keeper/handshake.go | 24 +- modules/core/03-connection/keeper/keeper.go | 44 +- .../core/03-connection/keeper/migrations.go | 2 +- modules/core/04-channel/keeper/events.go | 750 +++++++++--------- modules/core/04-channel/keeper/grpc_query.go | 8 +- modules/core/04-channel/keeper/handshake.go | 38 +- modules/core/04-channel/keeper/keeper.go | 125 ++- modules/core/04-channel/keeper/migrations.go | 2 +- modules/core/04-channel/keeper/packet.go | 54 +- modules/core/04-channel/keeper/timeout.go | 20 +- modules/core/04-channel/keeper/upgrade.go | 31 +- modules/core/05-port/keeper/keeper.go | 12 - modules/core/keeper/keeper.go | 13 +- modules/core/keeper/keeper_test.go | 5 +- modules/core/keeper/msg_server.go | 392 +++++---- modules/core/keeper/msg_server_test.go | 39 +- modules/core/module.go | 2 +- .../migrations/expected_keepers.go | 2 - .../07-tendermint/migrations/migrations.go | 3 +- .../08-wasm/testing/simapp/app.go | 6 +- .../09-localhost/light_client_module.go | 16 +- simapp/app.go | 6 +- testing/chain.go | 3 +- testing/simapp/app.go | 6 +- 33 files changed, 1027 insertions(+), 1038 deletions(-) diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index aefbaf96bc6..69dba479e1e 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -404,7 +404,11 @@ func NewSimApp( app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper) app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")), + app.GetSubspace(ibcexported.ModuleName), + app.UpgradeKeeper, + govModuleAddr, ) // NOTE: The mock ContractKeeper is only created for testing. diff --git a/modules/core/02-client/abci.go b/modules/core/02-client/abci.go index 1b582a36e93..8117ee01910 100644 --- a/modules/core/02-client/abci.go +++ b/modules/core/02-client/abci.go @@ -1,6 +1,8 @@ package client import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/02-client/keeper" @@ -9,7 +11,11 @@ import ( ) // BeginBlocker is used to perform IBC client upgrades -func BeginBlocker(ctx sdk.Context, k *keeper.Keeper) { +func BeginBlocker(goCtx context.Context, k *keeper.Keeper) { + // TODO: In order to fully migrate away from sdk.Context here we will need to depend on comet service in order + // to consume the full block header as Env only contains header.Info (where we cannot access next vals hash) + ctx := sdk.UnwrapSDKContext(goCtx) + plan, err := k.GetUpgradePlan(ctx) if err == nil { // Once we are at the last block this chain will commit, set the upgraded consensus state @@ -29,7 +35,9 @@ func BeginBlocker(ctx sdk.Context, k *keeper.Keeper) { // SetUpgradedConsensusState always returns nil, hence the blank here. _ = k.SetUpgradedConsensusState(ctx, plan.Height, bz) - keeper.EmitUpgradeChainEvent(ctx, plan.Height) + if err := k.EmitUpgradeChainEvent(ctx, plan.Height); err != nil { + k.Logger.Error("error in events emission", "error", err.Error()) + } } } } diff --git a/modules/core/02-client/keeper/client.go b/modules/core/02-client/keeper/client.go index 422fca31ba3..99a14adb1a4 100644 --- a/modules/core/02-client/keeper/client.go +++ b/modules/core/02-client/keeper/client.go @@ -1,9 +1,9 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" + "context" - sdk "github.com/cosmos/cosmos-sdk/types" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -15,7 +15,7 @@ import ( // client identifier. The light client module is responsible for setting any client-specific data in the store // via the Initialize method. This includes the client state, initial consensus state and any associated // metadata. The generated client identifier will be returned if a client was successfully initialized. -func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, consensusState []byte) (string, error) { +func (k *Keeper) CreateClient(ctx context.Context, clientType string, clientState, consensusState []byte) (string, error) { if clientType == exported.Localhost { return "", errorsmod.Wrapf(types.ErrInvalidClientType, "cannot create client of type: %s", clientType) } @@ -36,16 +36,18 @@ func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, c } initialHeight := clientModule.LatestHeight(ctx, clientID) - k.Logger(ctx).Info("client created at height", "client-id", clientID, "height", initialHeight.String()) + k.Logger.Info("client created at height", "client-id", clientID, "height", initialHeight.String()) defer telemetry.ReportCreateClient(clientType) - emitCreateClientEvent(ctx, clientID, clientType, initialHeight) + if err := k.emitCreateClientEvent(ctx, clientID, clientType, initialHeight); err != nil { + return "", err + } return clientID, nil } // UpdateClient updates the consensus state and the state root from a provided header. -func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error { +func (k *Keeper) UpdateClient(ctx context.Context, clientID string, clientMsg exported.ClientMessage) error { clientModule, err := k.Route(ctx, clientID) if err != nil { return err @@ -63,33 +65,27 @@ func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg export if foundMisbehaviour { clientModule.UpdateStateOnMisbehaviour(ctx, clientID, clientMsg) - k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID) + k.Logger.Info("client frozen due to misbehaviour", "client-id", clientID) clientType := types.MustParseClientIdentifier(clientID) defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID) - emitSubmitMisbehaviourEvent(ctx, clientID, clientType) - return nil + return k.emitSubmitMisbehaviourEvent(ctx, clientID, clientType) } consensusHeights := clientModule.UpdateState(ctx, clientID, clientMsg) - k.Logger(ctx).Info("client state updated", "client-id", clientID, "heights", consensusHeights) + k.Logger.Info("client state updated", "client-id", clientID, "heights", consensusHeights) clientType := types.MustParseClientIdentifier(clientID) defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID) - emitUpdateClientEvent(ctx, clientID, clientType, consensusHeights, k.cdc, clientMsg) - return nil + return k.emitUpdateClientEvent(ctx, clientID, clientType, consensusHeights, k.cdc, clientMsg) } // UpgradeClient upgrades the client to a new client state if this new client was committed to // by the old client at the specified upgrade height -func (k *Keeper) UpgradeClient( - ctx sdk.Context, - clientID string, - upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof []byte, -) error { +func (k *Keeper) UpgradeClient(ctx context.Context, clientID string, upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof []byte) error { clientModule, err := k.Route(ctx, clientID) if err != nil { return err @@ -104,13 +100,12 @@ func (k *Keeper) UpgradeClient( } latestHeight := clientModule.LatestHeight(ctx, clientID) - k.Logger(ctx).Info("client state upgraded", "client-id", clientID, "height", latestHeight.String()) + k.Logger.Info("client state upgraded", "client-id", clientID, "height", latestHeight.String()) clientType := types.MustParseClientIdentifier(clientID) defer telemetry.ReportUpgradeClient(clientType, clientID) - emitUpgradeClientEvent(ctx, clientID, clientType, latestHeight) - return nil + return k.emitUpgradeClientEvent(ctx, clientID, clientType, latestHeight) } // RecoverClient will invoke the light client module associated with the subject clientID requesting it to @@ -118,7 +113,7 @@ func (k *Keeper) UpgradeClient( // is responsible for validating the parameters of the substitute (ensuring they match the subject's parameters) // as well as copying the necessary consensus states from the substitute to the subject client store. // The substitute must be Active and the subject must not be Active. -func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClientID string) error { +func (k *Keeper) RecoverClient(ctx context.Context, subjectClientID, substituteClientID string) error { clientModule, err := k.Route(ctx, subjectClientID) if err != nil { return errorsmod.Wrap(types.ErrRouteNotFound, subjectClientID) @@ -142,11 +137,10 @@ func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClien return err } - k.Logger(ctx).Info("client recovered", "client-id", subjectClientID) + k.Logger.Info("client recovered", "client-id", subjectClientID) clientType := types.MustParseClientIdentifier(subjectClientID) defer telemetry.ReportRecoverClient(clientType, subjectClientID) - emitRecoverClientEvent(ctx, subjectClientID, clientType) - return nil + return k.emitRecoverClientEvent(ctx, subjectClientID, clientType) } diff --git a/modules/core/02-client/keeper/events.go b/modules/core/02-client/keeper/events.go index 6727ede5b7a..0db3e6cc915 100644 --- a/modules/core/02-client/keeper/events.go +++ b/modules/core/02-client/keeper/events.go @@ -1,10 +1,12 @@ package keeper import ( + "context" "fmt" "strconv" "strings" + "cosmossdk.io/core/event" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/codec" @@ -15,23 +17,24 @@ import ( ) // emitCreateClientEvent emits a create client event -func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, initialHeight exported.Height) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeCreateClient, - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientType), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitCreateClientEvent(ctx context.Context, clientID, clientType string, initialHeight exported.Height) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeCreateClient, + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyClientType, clientType), + event.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitUpdateClientEvent emits an update client event -func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, consensusHeights []exported.Height, _ codec.BinaryCodec, _ exported.ClientMessage) { +func (k *Keeper) emitUpdateClientEvent(ctx context.Context, clientID string, clientType string, consensusHeights []exported.Height, _ codec.BinaryCodec, _ exported.ClientMessage) error { var consensusHeightAttr string if len(consensusHeights) != 0 { consensusHeightAttr = consensusHeights[0].String() @@ -42,95 +45,101 @@ func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, consensusHeightsAttr[i] = height.String() } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpdateClient, - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientType), - // Deprecated: AttributeKeyConsensusHeight is deprecated and will be removed in a future release. - // Please use AttributeKeyConsensusHeights instead. - sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeightAttr), - sdk.NewAttribute(types.AttributeKeyConsensusHeights, strings.Join(consensusHeightsAttr, ",")), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeUpdateClient, + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyClientType, clientType), + // Deprecated: AttributeKeyConsensusHeight is deprecated and will be removed in a future release. + // Please use AttributeKeyConsensusHeights instead. + event.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeightAttr), + event.NewAttribute(types.AttributeKeyConsensusHeights, strings.Join(consensusHeightsAttr, ",")), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitUpgradeClientEvent emits an upgrade client event -func emitUpgradeClientEvent(ctx sdk.Context, clientID, clientType string, latestHeight exported.Height) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpgradeClient, - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientType), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitUpgradeClientEvent(ctx context.Context, clientID, clientType string, latestHeight exported.Height) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeUpgradeClient, + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyClientType, clientType), + event.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitSubmitMisbehaviourEvent emits a client misbehaviour event -func emitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientType string) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeSubmitMisbehaviour, - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientType), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitSubmitMisbehaviourEvent(ctx context.Context, clientID string, clientType string) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeSubmitMisbehaviour, + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyClientType, clientType), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitRecoverClientEvent emits a recover client event -func emitRecoverClientEvent(ctx sdk.Context, clientID, clientType string) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRecoverClient, - sdk.NewAttribute(types.AttributeKeySubjectClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientType), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitRecoverClientEvent(ctx context.Context, clientID, clientType string) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeRecoverClient, + event.NewAttribute(types.AttributeKeySubjectClientID, clientID), + event.NewAttribute(types.AttributeKeyClientType, clientType), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitScheduleIBCSoftwareUpgradeEvent emits a schedule IBC software upgrade event -func emitScheduleIBCSoftwareUpgradeEvent(ctx sdk.Context, title string, height int64) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeScheduleIBCSoftwareUpgrade, - sdk.NewAttribute(types.AttributeKeyUpgradePlanTitle, title), - sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitScheduleIBCSoftwareUpgradeEvent(ctx context.Context, title string, height int64) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeScheduleIBCSoftwareUpgrade, + event.NewAttribute(types.AttributeKeyUpgradePlanTitle, title), + event.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitUpgradeChainEvent emits an upgrade chain event. -func EmitUpgradeChainEvent(ctx sdk.Context, height int64) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUpgradeChain, - sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), - sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitUpgradeChainEvent(ctx context.Context, height int64) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeUpgradeChain, + event.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)), + event.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index bc075121731..3f7aa9ac3e6 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -75,7 +75,7 @@ func (q *queryServer) ClientStates(ctx context.Context, req *types.QueryClientSt } var clientStates types.IdentifiedClientStates - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.KeyClientStorePrefix) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), host.KeyClientStorePrefix) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { // filter any metadata stored under client state key @@ -166,7 +166,7 @@ func (q *queryServer) ConsensusStates(ctx context.Context, req *types.QueryConse } var consensusStates []types.ConsensusStateWithHeight - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { // filter any metadata stored under consensus state key @@ -208,7 +208,7 @@ func (q *queryServer) ConsensusStateHeights(ctx context.Context, req *types.Quer } var consensusStateHeights []types.Height - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, _ []byte, accumulate bool) (bool, error) { // filter any metadata stored under consensus state key @@ -294,16 +294,15 @@ func (q *queryServer) UpgradedClientState(ctx context.Context, req *types.QueryU } // UpgradedConsensusState implements the Query/UpgradedConsensusState gRPC method -func (q *queryServer) UpgradedConsensusState(c context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) { +func (q *queryServer) UpgradedConsensusState(ctx context.Context, req *types.QueryUpgradedConsensusStateRequest) (*types.QueryUpgradedConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - - bz, err := q.GetUpgradedConsensusState(ctx, ctx.BlockHeight()) + height := q.HeaderService.HeaderInfo(ctx).Height + bz, err := q.GetUpgradedConsensusState(ctx, height) if err != nil { - return nil, status.Errorf(codes.NotFound, "%s, height %d", err.Error(), ctx.BlockHeight()) + return nil, status.Errorf(codes.NotFound, "%s, height %d", err.Error(), height) } consensusState, err := types.UnmarshalConsensusState(q.cdc, bz) @@ -388,7 +387,7 @@ func (q *queryServer) VerifyMembership(c context.Context, req *types.QueryVerify ) if err := clientModule.VerifyMembership(cachedCtx, req.ClientId, req.ProofHeight, req.TimeDelay, req.BlockDelay, req.Proof, req.MerklePath, req.Value); err != nil { - q.Logger(ctx).Debug("proof verification failed", "key", req.MerklePath, "error", err) + q.Logger.Debug("proof verification failed", "key", req.MerklePath, "error", err) return &types.QueryVerifyMembershipResponse{ Success: false, }, nil diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index a921b8fc98f..9f843325d9a 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -6,9 +6,8 @@ import ( "fmt" "strings" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -28,7 +27,8 @@ import ( // Keeper represents a type that grants read and write permissions to any client // state information type Keeper struct { - storeService corestore.KVStoreService + appmodule.Environment + cdc codec.BinaryCodec router *types.Router legacySubspace types.ParamSubspace @@ -36,13 +36,13 @@ type Keeper struct { } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService, legacySubspace types.ParamSubspace, uk types.UpgradeKeeper) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, legacySubspace types.ParamSubspace, uk types.UpgradeKeeper) *Keeper { router := types.NewRouter() - localhostModule := localhost.NewLightClientModule(cdc, storeService) + localhostModule := localhost.NewLightClientModule(cdc, env) router.AddRoute(exported.Localhost, localhostModule) return &Keeper{ - storeService: storeService, + Environment: env, cdc: cdc, router: router, legacySubspace: legacySubspace, @@ -55,12 +55,6 @@ func (k *Keeper) Codec() codec.BinaryCodec { return k.cdc } -// Logger returns a module-specific logger. -func (Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) -} - // AddRoute adds a new route to the underlying router. func (k *Keeper) AddRoute(clientType string, module exported.LightClientModule) { k.router.AddRoute(clientType, module) @@ -68,7 +62,7 @@ func (k *Keeper) AddRoute(clientType string, module exported.LightClientModule) // GetStoreProvider returns the light client store provider. func (k *Keeper) GetStoreProvider() types.StoreProvider { - return types.NewStoreProvider(k.storeService) + return types.NewStoreProvider(k.KVStoreService) } // Route returns the light client module for the given client identifier. @@ -142,7 +136,7 @@ func (k *Keeper) SetClientConsensusState(ctx context.Context, clientID string, h // GetNextClientSequence gets the next client sequence from the store. func (k *Keeper) GetNextClientSequence(ctx context.Context) uint64 { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.KeyNextClientSequence)) if err != nil { panic(err) @@ -156,7 +150,7 @@ func (k *Keeper) GetNextClientSequence(ctx context.Context) uint64 { // SetNextClientSequence sets the next client sequence to the store. func (k *Keeper) SetNextClientSequence(ctx context.Context, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set([]byte(types.KeyNextClientSequence), bz); err != nil { panic(err) @@ -167,10 +161,10 @@ func (k *Keeper) SetNextClientSequence(ctx context.Context, sequence uint64) { // objects. For each State object, cb will be called. If the cb returns true, // the iterator will close and stop. func (k *Keeper) IterateConsensusStates(ctx context.Context, cb func(clientID string, cs types.ConsensusStateWithHeight) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.KeyClientStorePrefix) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") // consensus key is in the format "clients//consensusStates/" @@ -192,10 +186,10 @@ func (k *Keeper) IterateConsensusStates(ctx context.Context, cb func(clientID st // iterateMetadata provides an iterator over all stored metadata keys in the client store. // For each metadata object, it will perform a callback. func (k *Keeper) iterateMetadata(ctx context.Context, cb func(clientID string, key, value []byte) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.KeyClientStorePrefix) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { split := strings.Split(string(iterator.Key()), "/") if len(split) == 3 && split[2] == string(host.KeyClientState) { @@ -358,10 +352,10 @@ func (k *Keeper) SetUpgradedConsensusState(ctx context.Context, planHeight int64 // objects using the provided store prefix. For each ClientState object, cb will be called. If the cb returns true, // the iterator will close and stop. func (k *Keeper) IterateClientStates(ctx context.Context, storePrefix []byte, cb func(clientID string, cs exported.ClientState) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(storePrefix)) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { path := string(iterator.Key()) if !strings.Contains(path, host.KeyClientState) { @@ -393,7 +387,7 @@ func (k *Keeper) GetAllClients(ctx context.Context) []exported.ClientState { // namespace without being able to read/write other client's data func (k *Keeper) ClientStore(ctx context.Context, clientID string) storetypes.KVStore { clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) return prefix.NewStore(store, clientPrefix) } @@ -436,7 +430,7 @@ func (k *Keeper) GetClientTimestampAtHeight(ctx context.Context, clientID string // GetParams returns the total set of ibc-client parameters. func (k *Keeper) GetParams(ctx context.Context) types.Params { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.ParamsKey)) if err != nil { panic(err) @@ -452,7 +446,7 @@ func (k *Keeper) GetParams(ctx context.Context) types.Params { // SetParams sets the total set of ibc-client parameters. func (k *Keeper) SetParams(ctx context.Context, params types.Params) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(¶ms) if err := store.Set([]byte(types.ParamsKey), bz); err != nil { panic(err) @@ -484,8 +478,5 @@ func (k *Keeper) ScheduleIBCSoftwareUpgrade(ctx context.Context, plan upgradetyp } // emitting an event for scheduling an upgrade plan - sdkContext := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - emitScheduleIBCSoftwareUpgradeEvent(sdkContext, plan.Name, plan.Height) - - return nil + return k.emitScheduleIBCSoftwareUpgradeEvent(ctx, plan.Name, plan.Height) } diff --git a/modules/core/02-client/keeper/migrations.go b/modules/core/02-client/keeper/migrations.go index d39a756ed93..a66b783f522 100644 --- a/modules/core/02-client/keeper/migrations.go +++ b/modules/core/02-client/keeper/migrations.go @@ -26,7 +26,7 @@ func NewMigrator(keeper *Keeper) Migrator { // - removes the localhost client // - asserts that existing tendermint clients are properly registered on the chain codec func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v7.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc, m.keeper) + return v7.MigrateStore(ctx, m.keeper.KVStoreService, m.keeper.cdc, m.keeper) } // MigrateParams migrates from consensus version 4 to 5. @@ -40,7 +40,7 @@ func (m Migrator) MigrateParams(ctx sdk.Context) error { } m.keeper.SetParams(ctx, params) - m.keeper.Logger(ctx).Info("successfully migrated client to self-manage params") + m.keeper.Logger.Info("successfully migrated client to self-manage params") return nil } diff --git a/modules/core/03-connection/keeper/events.go b/modules/core/03-connection/keeper/events.go index 04d0bb4851d..a05ca272741 100644 --- a/modules/core/03-connection/keeper/events.go +++ b/modules/core/03-connection/keeper/events.go @@ -3,78 +3,80 @@ package keeper import ( "context" + "cosmossdk.io/core/event" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" ) // emitConnectionOpenInitEvent emits a connection open init event -func emitConnectionOpenInitEvent(ctx context.Context, connectionID string, clientID string, counterparty types.Counterparty) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeConnectionOpenInit, - sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitConnectionOpenInitEvent(ctx context.Context, connectionID string, clientID string, counterparty types.Counterparty) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeConnectionOpenInit, + event.NewAttribute(types.AttributeKeyConnectionID, connectionID), + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitConnectionOpenTryEvent emits a connection open try event -func emitConnectionOpenTryEvent(ctx context.Context, connectionID string, clientID string, counterparty types.Counterparty) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeConnectionOpenTry, - sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), - sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, counterparty.ConnectionId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitConnectionOpenTryEvent(ctx context.Context, connectionID string, clientID string, counterparty types.Counterparty) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeConnectionOpenTry, + event.NewAttribute(types.AttributeKeyConnectionID, connectionID), + event.NewAttribute(types.AttributeKeyClientID, clientID), + event.NewAttribute(types.AttributeKeyCounterpartyClientID, counterparty.ClientId), + event.NewAttribute(types.AttributeKeyCounterpartyConnectionID, counterparty.ConnectionId), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitConnectionOpenAckEvent emits a connection open acknowledge event -func emitConnectionOpenAckEvent(ctx context.Context, connectionID string, connectionEnd types.ConnectionEnd) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeConnectionOpenAck, - sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), - sdk.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitConnectionOpenAckEvent(ctx context.Context, connectionID string, connectionEnd types.ConnectionEnd) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeConnectionOpenAck, + event.NewAttribute(types.AttributeKeyConnectionID, connectionID), + event.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), + event.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), + event.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitConnectionOpenConfirmEvent emits a connection open confirm event -func emitConnectionOpenConfirmEvent(ctx context.Context, connectionID string, connectionEnd types.ConnectionEnd) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeConnectionOpenConfirm, - sdk.NewAttribute(types.AttributeKeyConnectionID, connectionID), - sdk.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), - sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitConnectionOpenConfirmEvent(ctx context.Context, connectionID string, connectionEnd types.ConnectionEnd) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeConnectionOpenConfirm, + event.NewAttribute(types.AttributeKeyConnectionID, connectionID), + event.NewAttribute(types.AttributeKeyClientID, connectionEnd.ClientId), + event.NewAttribute(types.AttributeKeyCounterpartyClientID, connectionEnd.Counterparty.ClientId), + event.NewAttribute(types.AttributeKeyCounterpartyConnectionID, connectionEnd.Counterparty.ConnectionId), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } diff --git a/modules/core/03-connection/keeper/grpc_query.go b/modules/core/03-connection/keeper/grpc_query.go index 859b6125332..c7d331f5f6e 100644 --- a/modules/core/03-connection/keeper/grpc_query.go +++ b/modules/core/03-connection/keeper/grpc_query.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" @@ -34,7 +33,7 @@ func NewQueryServer(k *Keeper) types.QueryServer { } // Connection implements the Query/Connection gRPC method -func (q *queryServer) Connection(c context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) { +func (q *queryServer) Connection(ctx context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -43,7 +42,6 @@ func (q *queryServer) Connection(c context.Context, req *types.QueryConnectionRe return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) connection, found := q.GetConnection(ctx, req.ConnectionId) if !found { return nil, status.Error( @@ -59,16 +57,14 @@ func (q *queryServer) Connection(c context.Context, req *types.QueryConnectionRe } // Connections implements the Query/Connections gRPC method -func (q *queryServer) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) { +func (q *queryServer) Connections(ctx context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - var connections []*types.IdentifiedConnection - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), []byte(host.KeyConnectionPrefix)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), []byte(host.KeyConnectionPrefix)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var result types.ConnectionEnd @@ -97,7 +93,7 @@ func (q *queryServer) Connections(c context.Context, req *types.QueryConnections } // ClientConnections implements the Query/ClientConnections gRPC method -func (q *queryServer) ClientConnections(c context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, error) { +func (q *queryServer) ClientConnections(ctx context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -106,7 +102,6 @@ func (q *queryServer) ClientConnections(c context.Context, req *types.QueryClien return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) clientConnectionPaths, found := q.GetClientConnectionPaths(ctx, req.ClientId) if !found { return nil, status.Error( @@ -122,7 +117,7 @@ func (q *queryServer) ClientConnections(c context.Context, req *types.QueryClien } // ConnectionClientState implements the Query/ConnectionClientState gRPC method -func (q *queryServer) ConnectionClientState(c context.Context, req *types.QueryConnectionClientStateRequest) (*types.QueryConnectionClientStateResponse, error) { +func (q *queryServer) ConnectionClientState(ctx context.Context, req *types.QueryConnectionClientStateRequest) (*types.QueryConnectionClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -131,8 +126,6 @@ func (q *queryServer) ConnectionClientState(c context.Context, req *types.QueryC return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) - connection, found := q.GetConnection(ctx, req.ConnectionId) if !found { return nil, status.Error( @@ -156,7 +149,7 @@ func (q *queryServer) ConnectionClientState(c context.Context, req *types.QueryC } // ConnectionConsensusState implements the Query/ConnectionConsensusState gRPC method -func (q *queryServer) ConnectionConsensusState(c context.Context, req *types.QueryConnectionConsensusStateRequest) (*types.QueryConnectionConsensusStateResponse, error) { +func (q *queryServer) ConnectionConsensusState(ctx context.Context, req *types.QueryConnectionConsensusStateRequest) (*types.QueryConnectionConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -165,8 +158,6 @@ func (q *queryServer) ConnectionConsensusState(c context.Context, req *types.Que return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) - connection, found := q.GetConnection(ctx, req.ConnectionId) if !found { return nil, status.Error( @@ -194,10 +185,8 @@ func (q *queryServer) ConnectionConsensusState(c context.Context, req *types.Que } // ConnectionParams implements the Query/ConnectionParams gRPC method. -func (q *queryServer) ConnectionParams(c context.Context, req *types.QueryConnectionParamsRequest) (*types.QueryConnectionParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +func (q *queryServer) ConnectionParams(ctx context.Context, req *types.QueryConnectionParamsRequest) (*types.QueryConnectionParamsResponse, error) { params := q.GetParams(ctx) - return &types.QueryConnectionParamsResponse{ Params: ¶ms, }, nil diff --git a/modules/core/03-connection/keeper/handshake.go b/modules/core/03-connection/keeper/handshake.go index 0b52d58991a..9700097dd47 100644 --- a/modules/core/03-connection/keeper/handshake.go +++ b/modules/core/03-connection/keeper/handshake.go @@ -47,11 +47,13 @@ func (k *Keeper) ConnOpenInit( connection := types.NewConnectionEnd(types.INIT, clientID, counterparty, versions, delayPeriod) k.SetConnection(ctx, connectionID, connection) - k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.UNINITIALIZED, "new-state", types.INIT) + k.Logger.Info("connection state updated", "connection-id", connectionID, "previous-state", types.UNINITIALIZED, "new-state", types.INIT) defer telemetry.IncrCounter(1, "ibc", "connection", "open-init") - emitConnectionOpenInitEvent(ctx, connectionID, clientID, counterparty) + if err := k.emitConnectionOpenInitEvent(ctx, connectionID, clientID, counterparty); err != nil { + return "", err + } return connectionID, nil } @@ -106,11 +108,13 @@ func (k *Keeper) ConnOpenTry( } k.SetConnection(ctx, connectionID, connection) - k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.UNINITIALIZED, "new-state", types.TRYOPEN) + k.Logger.Info("connection state updated", "connection-id", connectionID, "previous-state", types.UNINITIALIZED, "new-state", types.TRYOPEN) defer telemetry.IncrCounter(1, "ibc", "connection", "open-try") - emitConnectionOpenTryEvent(ctx, connectionID, clientID, counterparty) + if err := k.emitConnectionOpenTryEvent(ctx, connectionID, clientID, counterparty); err != nil { + return "", nil + } return connectionID, nil } @@ -161,7 +165,7 @@ func (k *Keeper) ConnOpenAck( return err } - k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.INIT, "new-state", types.OPEN) + k.Logger.Info("connection state updated", "connection-id", connectionID, "previous-state", types.INIT, "new-state", types.OPEN) defer telemetry.IncrCounter(1, "ibc", "connection", "open-ack") @@ -171,9 +175,7 @@ func (k *Keeper) ConnOpenAck( connection.Counterparty.ConnectionId = counterpartyConnectionID k.SetConnection(ctx, connectionID, connection) - emitConnectionOpenAckEvent(ctx, connectionID, connection) - - return nil + return k.emitConnectionOpenAckEvent(ctx, connectionID, connection) } // ConnOpenConfirm confirms opening of a connection on chain A to chain B, after @@ -215,11 +217,9 @@ func (k *Keeper) ConnOpenConfirm( // Update ChainB's connection to Open connection.State = types.OPEN k.SetConnection(ctx, connectionID, connection) - k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.TRYOPEN, "new-state", types.OPEN) + k.Logger.Info("connection state updated", "connection-id", connectionID, "previous-state", types.TRYOPEN, "new-state", types.OPEN) defer telemetry.IncrCounter(1, "ibc", "connection", "open-confirm") - emitConnectionOpenConfirmEvent(ctx, connectionID, connection) - - return nil + return k.emitConnectionOpenConfirmEvent(ctx, connectionID, connection) } diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index 328e6898420..f032e1fad81 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -4,9 +4,8 @@ import ( "context" "errors" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -23,31 +22,23 @@ import ( // Keeper defines the IBC connection keeper type Keeper struct { - // implements gRPC QueryServer interface - types.QueryServer + appmodule.Environment - storeService corestore.KVStoreService - legacySubspace types.ParamSubspace cdc codec.BinaryCodec clientKeeper types.ClientKeeper + legacySubspace types.ParamSubspace } // NewKeeper creates a new IBC connection Keeper instance -func NewKeeper(cdc codec.BinaryCodec, storeService corestore.KVStoreService, legacySubspace types.ParamSubspace, ck types.ClientKeeper) *Keeper { +func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, legacySubspace types.ParamSubspace, ck types.ClientKeeper) *Keeper { return &Keeper{ - storeService: storeService, + Environment: env, cdc: cdc, legacySubspace: legacySubspace, clientKeeper: ck, } } -// Logger returns a module-specific logger. -func (Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) -} - // GetCommitmentPrefix returns the IBC connection store prefix as a commitment // Prefix func (*Keeper) GetCommitmentPrefix() exported.Prefix { @@ -66,7 +57,7 @@ func (k *Keeper) GenerateConnectionIdentifier(ctx context.Context) string { // GetConnection returns a connection with a particular identifier func (k *Keeper) GetConnection(ctx context.Context, connectionID string) (types.ConnectionEnd, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ConnectionKey(connectionID)) if err != nil { panic(err) @@ -85,7 +76,7 @@ func (k *Keeper) GetConnection(ctx context.Context, connectionID string) (types. // HasConnection returns a true if the connection with the given identifier // exists in the store. func (k *Keeper) HasConnection(ctx context.Context, connectionID string) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.ConnectionKey(connectionID)) if err != nil { return false @@ -95,7 +86,7 @@ func (k *Keeper) HasConnection(ctx context.Context, connectionID string) bool { // SetConnection sets a connection to the store func (k *Keeper) SetConnection(ctx context.Context, connectionID string, connection types.ConnectionEnd) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&connection) if err := store.Set(host.ConnectionKey(connectionID), bz); err != nil { panic(err) @@ -105,7 +96,7 @@ func (k *Keeper) SetConnection(ctx context.Context, connectionID string, connect // GetClientConnectionPaths returns all the connection paths stored under a // particular client func (k *Keeper) GetClientConnectionPaths(ctx context.Context, clientID string) ([]string, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ClientConnectionsKey(clientID)) if err != nil { panic(err) @@ -122,7 +113,7 @@ func (k *Keeper) GetClientConnectionPaths(ctx context.Context, clientID string) // SetClientConnectionPaths sets the connections paths for client func (k *Keeper) SetClientConnectionPaths(ctx context.Context, clientID string, paths []string) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) clientPaths := types.ClientPaths{Paths: paths} bz := k.cdc.MustMarshal(&clientPaths) if err := store.Set(host.ClientConnectionsKey(clientID), bz); err != nil { @@ -132,7 +123,7 @@ func (k *Keeper) SetClientConnectionPaths(ctx context.Context, clientID string, // GetNextConnectionSequence gets the next connection sequence from the store. func (k *Keeper) GetNextConnectionSequence(ctx context.Context) uint64 { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.KeyNextConnectionSequence)) if err != nil { panic(err) @@ -147,7 +138,7 @@ func (k *Keeper) GetNextConnectionSequence(ctx context.Context) uint64 { // SetNextConnectionSequence sets the next connection sequence to the store. func (k *Keeper) SetNextConnectionSequence(ctx context.Context, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set([]byte(types.KeyNextConnectionSequence), bz); err != nil { panic(err) @@ -159,8 +150,7 @@ func (k *Keeper) SetNextConnectionSequence(ctx context.Context, sequence uint64) // no paths are stored. func (k *Keeper) GetAllClientConnectionPaths(ctx context.Context) []types.ConnectionPaths { var allConnectionPaths []types.ConnectionPaths - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - k.clientKeeper.IterateClientStates(sdkCtx, nil, func(clientID string, cs exported.ClientState) bool { + k.clientKeeper.IterateClientStates(ctx, nil, func(clientID string, cs exported.ClientState) bool { paths, found := k.GetClientConnectionPaths(ctx, clientID) if !found { // continue when connection handshake is not initialized @@ -178,11 +168,11 @@ func (k *Keeper) GetAllClientConnectionPaths(ctx context.Context) []types.Connec // For each ConnectionEnd, cb will be called. If the cb returns true, the // iterator will close and stop. func (k *Keeper) IterateConnections(ctx context.Context, cb func(types.IdentifiedConnection) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyConnectionPrefix)) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { var connection types.ConnectionEnd k.cdc.MustUnmarshal(iterator.Value(), &connection) @@ -232,7 +222,7 @@ func (k *Keeper) addConnectionToClient(ctx context.Context, clientID, connection // GetParams returns the total set of ibc-connection parameters. func (k *Keeper) GetParams(ctx context.Context) types.Params { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.ParamsKey)) if err != nil { panic(err) @@ -249,7 +239,7 @@ func (k *Keeper) GetParams(ctx context.Context) types.Params { // SetParams sets the total set of ibc-connection parameters. func (k *Keeper) SetParams(ctx context.Context, params types.Params) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(¶ms) if err := store.Set([]byte(types.ParamsKey), bz); err != nil { panic(err) diff --git a/modules/core/03-connection/keeper/migrations.go b/modules/core/03-connection/keeper/migrations.go index d668687d017..83503ebf971 100644 --- a/modules/core/03-connection/keeper/migrations.go +++ b/modules/core/03-connection/keeper/migrations.go @@ -35,6 +35,6 @@ func (m Migrator) MigrateParams(ctx sdk.Context) error { } m.keeper.SetParams(ctx, params) - m.keeper.Logger(ctx).Info("successfully migrated connection to self-manage params") + m.keeper.Logger.Info("successfully migrated connection to self-manage params") return nil } diff --git a/modules/core/04-channel/keeper/events.go b/modules/core/04-channel/keeper/events.go index fad33c9808b..fa8477ad387 100644 --- a/modules/core/04-channel/keeper/events.go +++ b/modules/core/04-channel/keeper/events.go @@ -5,6 +5,8 @@ import ( "encoding/hex" "fmt" + "cosmossdk.io/core/event" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" @@ -12,437 +14,447 @@ import ( ) // emitChannelOpenInitEvent emits a channel open init event -func emitChannelOpenInitEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelOpenInit, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyVersion, channel.Version), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelOpenInitEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelOpenInit, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + event.NewAttribute(types.AttributeKeyVersion, channel.Version), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelOpenTryEvent emits a channel open try event -func emitChannelOpenTryEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelOpenTry, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyVersion, channel.Version), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelOpenTryEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelOpenTry, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + event.NewAttribute(types.AttributeKeyVersion, channel.Version), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelOpenAckEvent emits a channel open acknowledge event -func emitChannelOpenAckEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelOpenAck, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelOpenAckEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelOpenAck, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelOpenConfirmEvent emits a channel open confirm event -func emitChannelOpenConfirmEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelOpenConfirm, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelOpenConfirmEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelOpenConfirm, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelCloseInitEvent emits a channel close init event -func emitChannelCloseInitEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelCloseInit, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelCloseInitEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelCloseInit, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelCloseConfirmEvent emits a channel close confirm event -func emitChannelCloseConfirmEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelCloseConfirm, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelCloseConfirmEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelCloseConfirm, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitSendPacketEvent emits an event with packet data along with other packet information for relayer // to pick up and relay to other chain -func emitSendPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeSendPacket, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - // we only support 1-hop packets now, and that is the most important hop for a relayer - // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitSendPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel, timeoutHeight exported.Height) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeSendPacket, + event.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + event.NewAttribute(types.AttributeKeyTimeoutHeight, timeoutHeight.String()), + event.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + event.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + event.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + event.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + // we only support 1-hop packets now, and that is the most important hop for a relayer + // (is it going to a chain I am connected to) + event.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitRecvPacketEvent emits a receive packet event. It will be emitted both the first time a packet // is received for a certain sequence and for all duplicate receives. -func emitRecvPacketEvent(ctx sdk.Context, packet types.Packet, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeRecvPacket, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - // we only support 1-hop packets now, and that is the most important hop for a relayer - // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitRecvPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeRecvPacket, + event.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + event.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + event.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + event.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + event.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + event.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + // we only support 1-hop packets now, and that is the most important hop for a relayer + // (is it going to a chain I am connected to) + event.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitWriteAcknowledgementEvent emits an event that the relayer can query for -func emitWriteAcknowledgementEvent(ctx sdk.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeWriteAck, - sdk.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - // we only support 1-hop packets now, and that is the most important hop for a relayer - // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitWriteAcknowledgementEvent(ctx context.Context, packet types.Packet, channel types.Channel, acknowledgement []byte) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeWriteAck, + event.NewAttribute(types.AttributeKeyDataHex, hex.EncodeToString(packet.GetData())), + event.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + event.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + event.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + event.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + event.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + event.NewAttribute(types.AttributeKeyAckHex, hex.EncodeToString(acknowledgement)), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + // we only support 1-hop packets now, and that is the most important hop for a relayer + // (is it going to a chain I am connected to) + event.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitAcknowledgePacketEvent emits an acknowledge packet event. It will be emitted both the first time // a packet is acknowledged for a certain sequence and for all duplicate acknowledgements. -func emitAcknowledgePacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAcknowledgePacket, - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - // we only support 1-hop packets now, and that is the most important hop for a relayer - // (is it going to a chain I am connected to) - sdk.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitAcknowledgePacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeAcknowledgePacket, + event.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + event.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + event.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + event.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + event.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + // we only support 1-hop packets now, and that is the most important hop for a relayer + // (is it going to a chain I am connected to) + event.NewAttribute(types.AttributeKeyConnection, channel.ConnectionHops[0]), // DEPRECATED + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitTimeoutPacketEvent emits a timeout packet event. It will be emitted both the first time a packet // is timed out for a certain sequence and for all duplicate timeouts. -func emitTimeoutPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeTimeoutPacket, - sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), - sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), - sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), - sdk.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), - sdk.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitTimeoutPacketEvent(ctx context.Context, packet types.Packet, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeTimeoutPacket, + event.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), + event.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), + event.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), + event.NewAttribute(types.AttributeKeySrcPort, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeySrcChannel, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeKeyDstPort, packet.GetDestPort()), + event.NewAttribute(types.AttributeKeyDstChannel, packet.GetDestChannel()), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelClosedEvent emits a channel closed event. -func emitChannelClosedEvent(ctx context.Context, packet types.Packet, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelClosed, - sdk.NewAttribute(types.AttributeKeyPortID, packet.GetSourcePort()), - sdk.NewAttribute(types.AttributeKeyChannelID, packet.GetSourceChannel()), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), - sdk.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelClosedEvent(ctx context.Context, packet types.Packet, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelClosed, + event.NewAttribute(types.AttributeKeyPortID, packet.GetSourcePort()), + event.NewAttribute(types.AttributeKeyChannelID, packet.GetSourceChannel()), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyConnectionID, channel.ConnectionHops[0]), + event.NewAttribute(types.AttributeKeyChannelOrdering, channel.Ordering.String()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeInitEvent emits a channel upgrade init event -func EmitChannelUpgradeInitEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeInit, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeInitEvent(ctx context.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeInit, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeTryEvent emits a channel upgrade try event -func EmitChannelUpgradeTryEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeTry, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeTryEvent(ctx context.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeTry, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeAckEvent emits a channel upgrade ack event -func EmitChannelUpgradeAckEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeAck, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeAckEvent(ctx context.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeAck, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeConfirmEvent emits a channel upgrade confirm event -func EmitChannelUpgradeConfirmEvent(ctx sdk.Context, portID, channelID string, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeConfirm, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeConfirmEvent(ctx context.Context, portID, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeConfirm, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeOpenEvent emits a channel upgrade open event -func EmitChannelUpgradeOpenEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeOpen, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeOpenEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeOpen, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeTimeoutEvent emits an upgrade timeout event. -func EmitChannelUpgradeTimeoutEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeTimeout, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeTimeoutHeight, upgrade.Timeout.Height.String()), - sdk.NewAttribute(types.AttributeKeyUpgradeTimeoutTimestamp, fmt.Sprintf("%d", upgrade.Timeout.Timestamp)), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeTimeoutEvent(ctx context.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeTimeout, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeTimeoutHeight, upgrade.Timeout.Height.String()), + event.NewAttribute(types.AttributeKeyUpgradeTimeoutTimestamp, fmt.Sprintf("%d", upgrade.Timeout.Timestamp)), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitErrorReceiptEvent emits an error receipt event -func EmitErrorReceiptEvent(ctx context.Context, portID string, channelID string, channel types.Channel, err error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeError, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - sdk.NewAttribute(types.AttributeKeyErrorReceipt, err.Error()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitErrorReceiptEvent(ctx context.Context, portID string, channelID string, channel types.Channel, err error) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeError, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + event.NewAttribute(types.AttributeKeyErrorReceipt, err.Error()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // EmitChannelUpgradeCancelEvent emits an upgraded cancelled event. -func EmitChannelUpgradeCancelEvent(ctx sdk.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) { - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelUpgradeCancel, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) EmitChannelUpgradeCancelEvent(ctx context.Context, portID string, channelID string, channel types.Channel, upgrade types.Upgrade) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelUpgradeCancel, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyUpgradeSequence, fmt.Sprintf("%d", channel.UpgradeSequence)), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } // emitChannelFlushCompleteEvent emits an flushing event. -func emitChannelFlushCompleteEvent(ctx context.Context, portID string, channelID string, channel types.Channel) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeChannelFlushComplete, - sdk.NewAttribute(types.AttributeKeyPortID, portID), - sdk.NewAttribute(types.AttributeKeyChannelID, channelID), - sdk.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), - sdk.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), - sdk.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - ), - }) +func (k *Keeper) emitChannelFlushCompleteEvent(ctx context.Context, portID string, channelID string, channel types.Channel) error { + if err := k.EventService.EventManager(ctx).EmitKV( + types.EventTypeChannelFlushComplete, + event.NewAttribute(types.AttributeKeyPortID, portID), + event.NewAttribute(types.AttributeKeyChannelID, channelID), + event.NewAttribute(types.AttributeCounterpartyPortID, channel.Counterparty.PortId), + event.NewAttribute(types.AttributeCounterpartyChannelID, channel.Counterparty.ChannelId), + event.NewAttribute(types.AttributeKeyChannelState, channel.State.String()), + ); err != nil { + return err + } + + return k.EventService.EventManager(ctx).EmitKV( + sdk.EventTypeMessage, + event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ) } diff --git a/modules/core/04-channel/keeper/grpc_query.go b/modules/core/04-channel/keeper/grpc_query.go index 648a8028534..d2ef8fed802 100644 --- a/modules/core/04-channel/keeper/grpc_query.go +++ b/modules/core/04-channel/keeper/grpc_query.go @@ -65,7 +65,7 @@ func (q *queryServer) Channels(ctx context.Context, req *types.QueryChannelsRequ } var channels []*types.IdentifiedChannel - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), []byte(host.KeyChannelEndPrefix)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), []byte(host.KeyChannelEndPrefix)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var result types.Channel @@ -106,7 +106,7 @@ func (q *queryServer) ConnectionChannels(ctx context.Context, req *types.QueryCo var channels []*types.IdentifiedChannel - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), []byte(host.KeyChannelEndPrefix)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), []byte(host.KeyChannelEndPrefix)) pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { // filter any metadata stored under channel key @@ -254,7 +254,7 @@ func (q *queryServer) PacketCommitments(ctx context.Context, req *types.QueryPac ) } var commitments []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.PacketCommitmentPrefixKey(req.PortId, req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), host.PacketCommitmentPrefixKey(req.PortId, req.ChannelId)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { keySplit := strings.Split(string(key), "/") @@ -352,7 +352,7 @@ func (q *queryServer) PacketAcknowledgements(ctx context.Context, req *types.Que ) } var acks []*types.PacketState - store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.PacketAcknowledgementPrefixKey(req.PortId, req.ChannelId)) + store := prefix.NewStore(runtime.KVStoreAdapter(q.KVStoreService.OpenKVStore(ctx)), host.PacketAcknowledgementPrefixKey(req.PortId, req.ChannelId)) // if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences) // otherwise, maintain previous behaviour and perform paginated query diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 635b178e067..a3c49629574 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -76,11 +76,13 @@ func (k *Keeper) WriteOpenInitChannel( k.SetNextSequenceRecv(ctx, portID, channelID, 1) k.SetNextSequenceAck(ctx, portID, channelID, 1) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.UNINITIALIZED, "new-state", types.INIT) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.UNINITIALIZED, "new-state", types.INIT) defer telemetry.IncrCounter(1, "ibc", "channel", "open-init") - emitChannelOpenInitEvent(ctx, portID, channelID, channel) + if err := k.emitChannelOpenInitEvent(ctx, portID, channelID, channel); err != nil { + panic(err) + } } // ChanOpenTry is called by a module to accept the first step of a channel opening @@ -169,11 +171,13 @@ func (k *Keeper) WriteOpenTryChannel( k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.UNINITIALIZED, "new-state", types.TRYOPEN) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.UNINITIALIZED, "new-state", types.TRYOPEN) defer telemetry.IncrCounter(1, "ibc", "channel", "open-try") - emitChannelOpenTryEvent(ctx, portID, channelID, channel) + if err := k.emitChannelOpenTryEvent(ctx, portID, channelID, channel); err != nil { + panic(err) + } } // ChanOpenAck is called by the handshake-originating module to acknowledge the @@ -239,11 +243,13 @@ func (k *Keeper) WriteOpenAckChannel( channel.Counterparty.ChannelId = counterpartyChannelID k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.INIT, "new-state", types.OPEN) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.INIT, "new-state", types.OPEN) defer telemetry.IncrCounter(1, "ibc", "channel", "open-ack") - emitChannelOpenAckEvent(ctx, portID, channelID, channel) + if err := k.emitChannelOpenAckEvent(ctx, portID, channelID, channel); err != nil { + panic(err) + } } // ChanOpenConfirm is called by the handshake-accepting module to confirm the acknowledgement @@ -306,11 +312,13 @@ func (k *Keeper) WriteOpenConfirmChannel( channel.State = types.OPEN k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.TRYOPEN, "new-state", types.OPEN) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.TRYOPEN, "new-state", types.OPEN) defer telemetry.IncrCounter(1, "ibc", "channel", "open-confirm") - emitChannelOpenConfirmEvent(ctx, portID, channelID, channel) + if err := k.emitChannelOpenConfirmEvent(ctx, portID, channelID, channel); err != nil { + panic(err) + } } // Closing Handshake @@ -347,16 +355,14 @@ func (k *Keeper) ChanCloseInit( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.State) } - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", channel.State, "new-state", types.CLOSED) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", channel.State, "new-state", types.CLOSED) defer telemetry.IncrCounter(1, "ibc", "channel", "close-init") channel.State = types.CLOSED k.SetChannel(ctx, portID, channelID, channel) - emitChannelCloseInitEvent(ctx, portID, channelID, channel) - - return nil + return k.emitChannelCloseInitEvent(ctx, portID, channelID, channel) } // ChanCloseConfirm is called by the counterparty module to close their end of the @@ -410,7 +416,7 @@ func (k *Keeper) ChanCloseConfirm( // If the channel is closing during an upgrade, then we can delete all upgrade information. if k.hasUpgrade(ctx, portID, channelID) { k.deleteUpgradeInfo(ctx, portID, channelID) - k.Logger(ctx).Info( + k.Logger.Info( "upgrade info deleted", "port_id", portID, "channel_id", channelID, @@ -418,14 +424,12 @@ func (k *Keeper) ChanCloseConfirm( ) } - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", channel.State, "new-state", types.CLOSED) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", channel.State, "new-state", types.CLOSED) defer telemetry.IncrCounter(1, "ibc", "channel", "close-confirm") channel.State = types.CLOSED k.SetChannel(ctx, portID, channelID, channel) - emitChannelCloseConfirmEvent(ctx, portID, channelID, channel) - - return nil + return k.emitChannelCloseConfirmEvent(ctx, portID, channelID, channel) } diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 35ee0451afa..c14f6aa49c8 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -8,9 +8,8 @@ import ( db "github.com/cosmos/cosmos-db" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -30,10 +29,8 @@ var _ porttypes.ICS4Wrapper = (*Keeper)(nil) // Keeper defines the IBC channel keeper type Keeper struct { - // implements gRPC QueryServer interface - types.QueryServer + appmodule.Environment - storeService corestore.KVStoreService cdc codec.BinaryCodec clientKeeper types.ClientKeeper connectionKeeper types.ConnectionKeeper @@ -42,24 +39,18 @@ type Keeper struct { // NewKeeper creates a new IBC channel Keeper instance func NewKeeper( cdc codec.BinaryCodec, - storeService corestore.KVStoreService, + env appmodule.Environment, clientKeeper types.ClientKeeper, connectionKeeper types.ConnectionKeeper, ) *Keeper { return &Keeper{ - storeService: storeService, + Environment: env, cdc: cdc, clientKeeper: clientKeeper, connectionKeeper: connectionKeeper, } } -// Logger returns a module-specific logger. -func (Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) -} - // GenerateChannelIdentifier returns the next channel identifier. func (k *Keeper) GenerateChannelIdentifier(ctx context.Context) string { nextChannelSeq := k.GetNextChannelSequence(ctx) @@ -72,7 +63,7 @@ func (k *Keeper) GenerateChannelIdentifier(ctx context.Context) string { // HasChannel true if the channel with the given identifiers exists in state. func (k *Keeper) HasChannel(ctx context.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.ChannelKey(portID, channelID)) if err != nil { panic(err) @@ -82,7 +73,7 @@ func (k *Keeper) HasChannel(ctx context.Context, portID, channelID string) bool // GetChannel returns a channel with a particular identifier binded to a specific port func (k *Keeper) GetChannel(ctx context.Context, portID, channelID string) (types.Channel, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ChannelKey(portID, channelID)) if err != nil { panic(err) @@ -98,7 +89,7 @@ func (k *Keeper) GetChannel(ctx context.Context, portID, channelID string) (type // SetChannel sets a channel to the store func (k *Keeper) SetChannel(ctx context.Context, portID, channelID string, channel types.Channel) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&channel) if err := store.Set(host.ChannelKey(portID, channelID), bz); err != nil { panic(err) @@ -117,7 +108,7 @@ func (k *Keeper) GetAppVersion(ctx context.Context, portID, channelID string) (s // GetNextChannelSequence gets the next channel sequence from the store. func (k *Keeper) GetNextChannelSequence(ctx context.Context) uint64 { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.KeyNextChannelSequence)) if err != nil { panic(err) @@ -131,7 +122,7 @@ func (k *Keeper) GetNextChannelSequence(ctx context.Context) uint64 { // SetNextChannelSequence sets the next channel sequence to the store. func (k *Keeper) SetNextChannelSequence(ctx context.Context, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set([]byte(types.KeyNextChannelSequence), bz); err != nil { panic(err) @@ -140,7 +131,7 @@ func (k *Keeper) SetNextChannelSequence(ctx context.Context, sequence uint64) { // GetNextSequenceSend gets a channel's next send sequence from the store func (k *Keeper) GetNextSequenceSend(ctx context.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.NextSequenceSendKey(portID, channelID)) if err != nil { panic(err) @@ -154,7 +145,7 @@ func (k *Keeper) GetNextSequenceSend(ctx context.Context, portID, channelID stri // SetNextSequenceSend sets a channel's next send sequence to the store func (k *Keeper) SetNextSequenceSend(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set(host.NextSequenceSendKey(portID, channelID), bz); err != nil { panic(err) @@ -163,7 +154,7 @@ func (k *Keeper) SetNextSequenceSend(ctx context.Context, portID, channelID stri // GetNextSequenceRecv gets a channel's next receive sequence from the store func (k *Keeper) GetNextSequenceRecv(ctx context.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.NextSequenceRecvKey(portID, channelID)) if err != nil { panic(err) @@ -177,7 +168,7 @@ func (k *Keeper) GetNextSequenceRecv(ctx context.Context, portID, channelID stri // SetNextSequenceRecv sets a channel's next receive sequence to the store func (k *Keeper) SetNextSequenceRecv(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set(host.NextSequenceRecvKey(portID, channelID), bz); err != nil { panic(err) @@ -186,7 +177,7 @@ func (k *Keeper) SetNextSequenceRecv(ctx context.Context, portID, channelID stri // GetNextSequenceAck gets a channel's next ack sequence from the store func (k *Keeper) GetNextSequenceAck(ctx context.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.NextSequenceAckKey(portID, channelID)) if err != nil { panic(err) @@ -201,7 +192,7 @@ func (k *Keeper) GetNextSequenceAck(ctx context.Context, portID, channelID strin // SetNextSequenceAck sets a channel's next ack sequence to the store func (k *Keeper) SetNextSequenceAck(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set(host.NextSequenceAckKey(portID, channelID), bz); err != nil { panic(err) @@ -210,7 +201,7 @@ func (k *Keeper) SetNextSequenceAck(ctx context.Context, portID, channelID strin // GetPacketReceipt gets a packet receipt from the store func (k *Keeper) GetPacketReceipt(ctx context.Context, portID, channelID string, sequence uint64) (string, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.PacketReceiptKey(portID, channelID, sequence)) if err != nil { panic(err) @@ -225,7 +216,7 @@ func (k *Keeper) GetPacketReceipt(ctx context.Context, portID, channelID string, // SetPacketReceipt sets an empty packet receipt to the store func (k *Keeper) SetPacketReceipt(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Set(host.PacketReceiptKey(portID, channelID, sequence), []byte{byte(1)}); err != nil { panic(err) } @@ -233,7 +224,7 @@ func (k *Keeper) SetPacketReceipt(ctx context.Context, portID, channelID string, // deletePacketReceipt deletes a packet receipt from the store func (k *Keeper) deletePacketReceipt(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Delete(host.PacketReceiptKey(portID, channelID, sequence)); err != nil { panic(err) } @@ -241,7 +232,7 @@ func (k *Keeper) deletePacketReceipt(ctx context.Context, portID, channelID stri // GetPacketCommitment gets the packet commitment hash from the store func (k *Keeper) GetPacketCommitment(ctx context.Context, portID, channelID string, sequence uint64) []byte { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.PacketCommitmentKey(portID, channelID, sequence)) if err != nil { panic(err) @@ -252,7 +243,7 @@ func (k *Keeper) GetPacketCommitment(ctx context.Context, portID, channelID stri // HasPacketCommitment returns true if the packet commitment exists func (k *Keeper) HasPacketCommitment(ctx context.Context, portID, channelID string, sequence uint64) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.PacketCommitmentKey(portID, channelID, sequence)) if err != nil { panic(err) @@ -262,14 +253,14 @@ func (k *Keeper) HasPacketCommitment(ctx context.Context, portID, channelID stri // SetPacketCommitment sets the packet commitment hash to the store func (k *Keeper) SetPacketCommitment(ctx context.Context, portID, channelID string, sequence uint64, commitmentHash []byte) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Set(host.PacketCommitmentKey(portID, channelID, sequence), commitmentHash); err != nil { panic(err) } } func (k *Keeper) deletePacketCommitment(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Delete(host.PacketCommitmentKey(portID, channelID, sequence)); err != nil { panic(err) } @@ -277,7 +268,7 @@ func (k *Keeper) deletePacketCommitment(ctx context.Context, portID, channelID s // SetPacketAcknowledgement sets the packet ack hash to the store func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, ackHash []byte) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Set(host.PacketAcknowledgementKey(portID, channelID, sequence), ackHash); err != nil { panic(err) } @@ -285,7 +276,7 @@ func (k *Keeper) SetPacketAcknowledgement(ctx context.Context, portID, channelID // GetPacketAcknowledgement gets the packet ack hash from the store func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64) ([]byte, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.PacketAcknowledgementKey(portID, channelID, sequence)) if err != nil { panic(err) @@ -300,7 +291,7 @@ func (k *Keeper) GetPacketAcknowledgement(ctx context.Context, portID, channelID // HasPacketAcknowledgement check if the packet ack hash is already on the store func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.PacketAcknowledgementKey(portID, channelID, sequence)) if err != nil { panic(err) @@ -310,7 +301,7 @@ func (k *Keeper) HasPacketAcknowledgement(ctx context.Context, portID, channelID // deletePacketAcknowledgement deletes the packet ack hash from the store func (k *Keeper) deletePacketAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Delete(host.PacketAcknowledgementKey(portID, channelID, sequence)); err != nil { panic(err) } @@ -320,7 +311,7 @@ func (k *Keeper) deletePacketAcknowledgement(ctx context.Context, portID, channe // For each sequence, cb will be called. If the cb returns true, the iterator // will close and stop. func (k *Keeper) IteratePacketSequence(ctx context.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64) bool) { - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { portID, channelID, err := host.ParseChannelPath(string(iterator.Key())) if err != nil { @@ -338,7 +329,7 @@ func (k *Keeper) IteratePacketSequence(ctx context.Context, iterator db.Iterator // GetAllPacketSendSeqs returns all stored next send sequences. func (k *Keeper) GetAllPacketSendSeqs(ctx context.Context) (seqs []types.PacketSequence) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqSendPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextSendSeq uint64) bool { ps := types.NewPacketSequence(portID, channelID, nextSendSeq) @@ -350,7 +341,7 @@ func (k *Keeper) GetAllPacketSendSeqs(ctx context.Context) (seqs []types.PacketS // GetAllPacketRecvSeqs returns all stored next recv sequences. func (k *Keeper) GetAllPacketRecvSeqs(ctx context.Context) (seqs []types.PacketSequence) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqRecvPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextRecvSeq uint64) bool { ps := types.NewPacketSequence(portID, channelID, nextRecvSeq) @@ -362,7 +353,7 @@ func (k *Keeper) GetAllPacketRecvSeqs(ctx context.Context) (seqs []types.PacketS // GetAllPacketAckSeqs returns all stored next acknowledgements sequences. func (k *Keeper) GetAllPacketAckSeqs(ctx context.Context) (seqs []types.PacketSequence) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyNextSeqAckPrefix)) k.IteratePacketSequence(ctx, iterator, func(portID, channelID string, nextAckSeq uint64) bool { ps := types.NewPacketSequence(portID, channelID, nextAckSeq) @@ -376,7 +367,7 @@ func (k *Keeper) GetAllPacketAckSeqs(ctx context.Context) (seqs []types.PacketSe // packet commitment, cb will be called. If the cb returns true, the iterator will close // and stop. func (k *Keeper) IteratePacketCommitment(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketCommitmentPrefix)) k.iterateHashes(ctx, iterator, cb) } @@ -395,7 +386,7 @@ func (k *Keeper) GetAllPacketCommitments(ctx context.Context) (commitments []typ // at a specified channel. For each packet commitment, cb will be called. If the cb returns // true, the iterator will close and stop. func (k *Keeper) IteratePacketCommitmentAtChannel(ctx context.Context, portID, channelID string, cb func(_, _ string, sequence uint64, hash []byte) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.PacketCommitmentPrefixKey(portID, channelID)) k.iterateHashes(ctx, iterator, cb) } @@ -415,7 +406,7 @@ func (k *Keeper) GetAllPacketCommitmentsAtChannel(ctx context.Context, portID, c // receipt, cb will be called. If the cb returns true, the iterator will close // and stop. func (k *Keeper) IteratePacketReceipt(ctx context.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix)) k.iterateHashes(ctx, iterator, cb) } @@ -434,7 +425,7 @@ func (k *Keeper) GetAllPacketReceipts(ctx context.Context) (receipts []types.Pac // acknowledgement, cb will be called. If the cb returns true, the iterator will close // and stop. func (k *Keeper) IteratePacketAcknowledgement(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketAckPrefix)) k.iterateHashes(ctx, iterator, cb) } @@ -453,10 +444,10 @@ func (k *Keeper) GetAllPacketAcks(ctx context.Context) (acks []types.PacketState // Channel, cb will be called. If the cb returns true, the iterator will close // and stop. func (k *Keeper) IterateChannels(ctx context.Context, cb func(types.IdentifiedChannel) bool) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyChannelEndPrefix)) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { var channel types.Channel k.cdc.MustUnmarshal(iterator.Value(), &channel) @@ -475,9 +466,9 @@ func (k *Keeper) GetAllChannelsWithPortPrefix(ctx context.Context, portPrefix st if strings.TrimSpace(portPrefix) == "" { return k.GetAllChannels(ctx) } - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, types.FilteredPortPrefix(portPrefix)) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) var filteredChannels []types.IdentifiedChannel for ; iterator.Valid(); iterator.Next() { @@ -549,7 +540,7 @@ func (k *Keeper) GetChannelConnection(ctx context.Context, portID, channelID str // GetUpgradeErrorReceipt returns the upgrade error receipt for the provided port and channel identifiers. func (k *Keeper) GetUpgradeErrorReceipt(ctx context.Context, portID, channelID string) (types.ErrorReceipt, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ChannelUpgradeErrorKey(portID, channelID)) if err != nil { panic(err) @@ -567,7 +558,7 @@ func (k *Keeper) GetUpgradeErrorReceipt(ctx context.Context, portID, channelID s // setUpgradeErrorReceipt sets the provided error receipt in store using the port and channel identifiers. func (k *Keeper) setUpgradeErrorReceipt(ctx context.Context, portID, channelID string, errorReceipt types.ErrorReceipt) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&errorReceipt) if err := store.Set(host.ChannelUpgradeErrorKey(portID, channelID), bz); err != nil { panic(err) @@ -576,7 +567,7 @@ func (k *Keeper) setUpgradeErrorReceipt(ctx context.Context, portID, channelID s // hasUpgrade returns true if a proposed upgrade exists in store func (k *Keeper) hasUpgrade(ctx context.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.ChannelUpgradeKey(portID, channelID)) if err != nil { panic(err) @@ -586,7 +577,7 @@ func (k *Keeper) hasUpgrade(ctx context.Context, portID, channelID string) bool // GetUpgrade returns the proposed upgrade for the provided port and channel identifiers. func (k *Keeper) GetUpgrade(ctx context.Context, portID, channelID string) (types.Upgrade, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ChannelUpgradeKey(portID, channelID)) if err != nil { panic(err) @@ -604,7 +595,7 @@ func (k *Keeper) GetUpgrade(ctx context.Context, portID, channelID string) (type // SetUpgrade sets the proposed upgrade using the provided port and channel identifiers. func (k *Keeper) SetUpgrade(ctx context.Context, portID, channelID string, upgrade types.Upgrade) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&upgrade) if err := store.Set(host.ChannelUpgradeKey(portID, channelID), bz); err != nil { panic(err) @@ -613,7 +604,7 @@ func (k *Keeper) SetUpgrade(ctx context.Context, portID, channelID string, upgra // deleteUpgrade deletes the upgrade for the provided port and channel identifiers. func (k *Keeper) deleteUpgrade(ctx context.Context, portID, channelID string) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Delete(host.ChannelUpgradeKey(portID, channelID)); err != nil { panic(err) } @@ -621,7 +612,7 @@ func (k *Keeper) deleteUpgrade(ctx context.Context, portID, channelID string) { // hasCounterpartyUpgrade returns true if a counterparty upgrade exists in store func (k *Keeper) hasCounterpartyUpgrade(ctx context.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.ChannelCounterpartyUpgradeKey(portID, channelID)) if err != nil { panic(err) @@ -631,7 +622,7 @@ func (k *Keeper) hasCounterpartyUpgrade(ctx context.Context, portID, channelID s // GetCounterpartyUpgrade gets the counterparty upgrade from the store. func (k *Keeper) GetCounterpartyUpgrade(ctx context.Context, portID, channelID string) (types.Upgrade, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.ChannelCounterpartyUpgradeKey(portID, channelID)) if err != nil { panic(err) @@ -649,7 +640,7 @@ func (k *Keeper) GetCounterpartyUpgrade(ctx context.Context, portID, channelID s // SetCounterpartyUpgrade sets the counterparty upgrade in the store. func (k *Keeper) SetCounterpartyUpgrade(ctx context.Context, portID, channelID string, upgrade types.Upgrade) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(&upgrade) if err := store.Set(host.ChannelCounterpartyUpgradeKey(portID, channelID), bz); err != nil { panic(err) @@ -658,7 +649,7 @@ func (k *Keeper) SetCounterpartyUpgrade(ctx context.Context, portID, channelID s // deleteCounterpartyUpgrade deletes the counterparty upgrade in the store. func (k *Keeper) deleteCounterpartyUpgrade(ctx context.Context, portID, channelID string) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) if err := store.Delete(host.ChannelCounterpartyUpgradeKey(portID, channelID)); err != nil { panic(err) } @@ -672,7 +663,7 @@ func (k *Keeper) deleteUpgradeInfo(ctx context.Context, portID, channelID string // SetParams sets the channel parameters. func (k *Keeper) SetParams(ctx context.Context, params types.Params) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := k.cdc.MustMarshal(¶ms) if err := store.Set([]byte(types.ParamsKey), bz); err != nil { panic(err) @@ -681,7 +672,7 @@ func (k *Keeper) SetParams(ctx context.Context, params types.Params) { // GetParams returns the total set of the channel parameters. func (k *Keeper) GetParams(ctx context.Context) types.Params { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get([]byte(types.ParamsKey)) if err != nil { panic(err) @@ -698,7 +689,7 @@ func (k *Keeper) GetParams(ctx context.Context) types.Params { // common functionality for IteratePacketCommitment and IteratePacketAcknowledgement func (k *Keeper) iterateHashes(ctx context.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") @@ -719,16 +710,16 @@ func (k *Keeper) iterateHashes(ctx context.Context, iterator db.Iterator, cb fun // HasInflightPackets returns true if there are packet commitments stored at the specified // port and channel, and false otherwise. func (k *Keeper) HasInflightPackets(ctx context.Context, portID, channelID string) bool { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.PacketCommitmentPrefixKey(portID, channelID)) - defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() }) + defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) return iterator.Valid() } // setRecvStartSequence sets the channel's recv start sequence to the store. func (k *Keeper) setRecvStartSequence(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set(host.RecvStartSequenceKey(portID, channelID), bz); err != nil { panic(err) @@ -740,7 +731,7 @@ func (k *Keeper) setRecvStartSequence(ctx context.Context, portID, channelID str // upon a successful channel upgrade. It will be used for replay protection of // historical packets and as the upper bound for pruning stale packet receives. func (k *Keeper) GetRecvStartSequence(ctx context.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.RecvStartSequenceKey(portID, channelID)) if err != nil { panic(err) @@ -755,7 +746,7 @@ func (k *Keeper) GetRecvStartSequence(ctx context.Context, portID, channelID str // SetPruningSequenceStart sets a channel's pruning sequence start to the store. func (k *Keeper) SetPruningSequenceStart(ctx context.Context, portID, channelID string, sequence uint64) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz := sdk.Uint64ToBigEndian(sequence) if err := store.Set(host.PruningSequenceStartKey(portID, channelID), bz); err != nil { panic(err) @@ -764,7 +755,7 @@ func (k *Keeper) SetPruningSequenceStart(ctx context.Context, portID, channelID // GetPruningSequenceStart gets a channel's pruning sequence start from the store. func (k *Keeper) GetPruningSequenceStart(ctx context.Context, portID, channelID string) (uint64, bool) { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) bz, err := store.Get(host.PruningSequenceStartKey(portID, channelID)) if err != nil { panic(err) @@ -779,7 +770,7 @@ func (k *Keeper) GetPruningSequenceStart(ctx context.Context, portID, channelID // HasPruningSequenceStart returns true if the pruning sequence start is set for the specified channel. func (k *Keeper) HasPruningSequenceStart(ctx context.Context, portID, channelID string) bool { - store := k.storeService.OpenKVStore(ctx) + store := k.KVStoreService.OpenKVStore(ctx) has, err := store.Has(host.PruningSequenceStartKey(portID, channelID)) if err != nil { panic(err) diff --git a/modules/core/04-channel/keeper/migrations.go b/modules/core/04-channel/keeper/migrations.go index 9a382d26265..c83cf865022 100644 --- a/modules/core/04-channel/keeper/migrations.go +++ b/modules/core/04-channel/keeper/migrations.go @@ -20,6 +20,6 @@ func NewMigrator(keeper *Keeper) Migrator { func (m Migrator) MigrateParams(ctx sdk.Context) error { params := channeltypes.DefaultParams() m.keeper.SetParams(ctx, params) - m.keeper.Logger(ctx).Info("successfully migrated ibc channel params") + m.keeper.Logger.Info("successfully migrated ibc channel params") return nil } diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index 65410bcd11b..19763a326e6 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -8,8 +8,6 @@ import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" @@ -36,8 +34,6 @@ func (k *Keeper) SendPacket( return 0, errorsmod.Wrapf(types.ErrInvalidChannelState, "channel is not OPEN (got %s)", channel.State) } - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - sequence, found := k.GetNextSequenceSend(ctx, sourcePort, sourceChannel) if !found { return 0, errorsmod.Wrapf( @@ -85,9 +81,11 @@ func (k *Keeper) SendPacket( k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1) k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment) - emitSendPacketEvent(sdkCtx, packet, channel, timeoutHeight) + if err := k.emitSendPacketEvent(ctx, packet, channel, timeoutHeight); err != nil { + return 0, err + } - k.Logger(ctx).Info( + k.Logger.Info( "packet sent", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", sourcePort, @@ -157,8 +155,7 @@ func (k *Keeper) RecvPacket( } // check if packet timed out by comparing it with the latest height of the chain - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(sdkCtx), uint64(sdkCtx.BlockTime().UnixNano()) + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(k.HeaderService.HeaderInfo(ctx).Time.UnixNano()) timeout := types.NewTimeout(packet.GetTimeoutHeight().(clienttypes.Height), packet.GetTimeoutTimestamp()) if timeout.Elapsed(selfHeight, selfTimestamp) { return "", errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "packet timeout elapsed") @@ -180,7 +177,7 @@ func (k *Keeper) RecvPacket( } // log that a packet has been received & executed - k.Logger(ctx).Info( + k.Logger.Info( "packet received", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), @@ -190,7 +187,9 @@ func (k *Keeper) RecvPacket( ) // emit an event that the relayer can query for - emitRecvPacketEvent(sdkCtx, packet, channel) + if err := k.emitRecvPacketEvent(ctx, packet, channel); err != nil { + return "", err + } return channel.Version, nil } @@ -207,7 +206,6 @@ func (k *Keeper) applyReplayProtection(ctx context.Context, packet types.Packet, return errorsmod.Wrap(types.ErrPacketReceived, "packet already processed in previous channel upgrade") } - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 switch channel.Ordering { case types.UNORDERED: // REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received @@ -215,7 +213,9 @@ func (k *Keeper) applyReplayProtection(ctx context.Context, packet types.Packet, // by the increase of the recvStartSequence. _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { - emitRecvPacketEvent(sdkCtx, packet, channel) + if err := k.emitRecvPacketEvent(ctx, packet, channel); err != nil { + return err + } // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -239,7 +239,9 @@ func (k *Keeper) applyReplayProtection(ctx context.Context, packet types.Packet, } if packet.GetSequence() < nextSequenceRecv { - emitRecvPacketEvent(sdkCtx, packet, channel) + if err := k.emitRecvPacketEvent(ctx, packet, channel); err != nil { + return err + } // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -325,7 +327,7 @@ func (k *Keeper) WriteAcknowledgement( ) // log that a packet acknowledgement has been written - k.Logger(ctx).Info( + k.Logger.Info( "acknowledgement written", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), @@ -334,10 +336,7 @@ func (k *Keeper) WriteAcknowledgement( "dst_channel", packet.GetDestChannel(), ) - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - emitWriteAcknowledgementEvent(sdkCtx, packet.(types.Packet), channel, bz) - - return nil + return k.emitWriteAcknowledgementEvent(ctx, packet.(types.Packet), channel, bz) } // AcknowledgePacket is called by a module to process the acknowledgement of a @@ -392,7 +391,9 @@ func (k *Keeper) AcknowledgePacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitAcknowledgePacketEvent(ctx, packet, channel) + if err := k.emitAcknowledgePacketEvent(ctx, packet, channel); err != nil { + return "", err + } // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -444,7 +445,7 @@ func (k *Keeper) AcknowledgePacket( k.deletePacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) // log that a packet has been acknowledged - k.Logger(ctx).Info( + k.Logger.Info( "packet acknowledged", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), @@ -454,7 +455,9 @@ func (k *Keeper) AcknowledgePacket( ) // emit an event marking that we have processed the acknowledgement - emitAcknowledgePacketEvent(ctx, packet, channel) + if err := k.emitAcknowledgePacketEvent(ctx, packet, channel); err != nil { + return "", err + } // if an upgrade is in progress, handling packet flushing and update channel state appropriately if channel.State == types.FLUSHING { @@ -471,19 +474,20 @@ func (k *Keeper) AcknowledgePacket( func (k *Keeper) handleFlushState(ctx context.Context, packet types.Packet, channel types.Channel) { if counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel()); found { timeout := counterpartyUpgrade.Timeout - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(sdkCtx), uint64(sdkCtx.BlockTime().UnixNano()) + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(k.HeaderService.HeaderInfo(ctx).Time.UnixNano()) if timeout.Elapsed(selfHeight, selfTimestamp) { // packet flushing timeout has expired, abort the upgrade // committing an error receipt to state, deleting upgrade information and restoring the channel. - k.Logger(ctx).Info("upgrade aborted", "port_id", packet.GetSourcePort(), "channel_id", packet.GetSourceChannel(), "upgrade_sequence", channel.UpgradeSequence) + k.Logger.Info("upgrade aborted", "port_id", packet.GetSourcePort(), "channel_id", packet.GetSourceChannel(), "upgrade_sequence", channel.UpgradeSequence) k.MustAbortUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp)) } else if !k.HasInflightPackets(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) { // set the channel state to flush complete if all packets have been acknowledged/flushed. channel.State = types.FLUSHCOMPLETE k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) - emitChannelFlushCompleteEvent(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) + if err := k.emitChannelFlushCompleteEvent(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel); err != nil { + panic(err) + } } } } diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 5b548605700..04dc96a9daf 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -70,7 +70,9 @@ func (k *Keeper) TimeoutPacket( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitTimeoutPacketEvent(ctx, packet, channel) + if err := k.emitTimeoutPacketEvent(ctx, packet, channel); err != nil { + return "", err + } // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -145,7 +147,7 @@ func (k *Keeper) TimeoutExecuted( // all upgrade information is deleted and the channel is set to CLOSED. if channel.State == types.FLUSHING { k.deleteUpgradeInfo(ctx, packet.GetSourcePort(), packet.GetSourceChannel()) - k.Logger(ctx).Info( + k.Logger.Info( "upgrade info deleted", "port_id", packet.GetSourcePort(), "channel_id", packet.GetSourceChannel(), @@ -155,10 +157,12 @@ func (k *Keeper) TimeoutExecuted( channel.State = types.CLOSED k.SetChannel(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), channel) - emitChannelClosedEvent(ctx, packet, channel) + if err := k.emitChannelClosedEvent(ctx, packet, channel); err != nil { + return err + } } - k.Logger(ctx).Info( + k.Logger.Info( "packet timed-out", "sequence", strconv.FormatUint(packet.GetSequence(), 10), "src_port", packet.GetSourcePort(), @@ -168,9 +172,7 @@ func (k *Keeper) TimeoutExecuted( ) // emit an event marking that we have processed the timeout - emitTimeoutPacketEvent(ctx, packet, channel) - - return nil + return k.emitTimeoutPacketEvent(ctx, packet, channel) } // TimeoutOnClose is called by a module in order to prove that the channel to @@ -212,7 +214,9 @@ func (k *Keeper) TimeoutOnClose( commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) if len(commitment) == 0 { - emitTimeoutPacketEvent(ctx, packet, channel) + if err := k.emitTimeoutPacketEvent(ctx, packet, channel); err != nil { + return "", err + } // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index cee41cbf4f0..b2c28e37d5b 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -9,7 +9,6 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" @@ -67,7 +66,7 @@ func (k *Keeper) WriteUpgradeInitChannel(ctx context.Context, portID, channelID k.SetChannel(ctx, portID, channelID, channel) k.SetUpgrade(ctx, portID, channelID, upgrade) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "state", channel.State, "upgrade-sequence", fmt.Sprintf("%d", channel.UpgradeSequence)) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "state", channel.State, "upgrade-sequence", fmt.Sprintf("%d", channel.UpgradeSequence)) return channel, upgrade } @@ -235,7 +234,7 @@ func (k *Keeper) WriteUpgradeTryChannel(ctx context.Context, portID, channelID s upgrade.Fields.Version = upgradeVersion k.SetUpgrade(ctx, portID, channelID, upgrade) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.OPEN, "new-state", channel.State) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", types.OPEN, "new-state", channel.State) return channel, upgrade } @@ -341,9 +340,7 @@ func (k *Keeper) ChanUpgradeAck( } timeout := counterpartyUpgrade.Timeout - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(sdkCtx), uint64(sdkCtx.BlockTime().UnixNano()) - + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(k.HeaderService.HeaderInfo(ctx).Time.UnixNano()) if timeout.Elapsed(selfHeight, selfTimestamp) { return types.NewUpgradeError(channel.UpgradeSequence, errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "counterparty upgrade timeout elapsed")) } @@ -366,7 +363,7 @@ func (k *Keeper) WriteUpgradeAckChannel(ctx context.Context, portID, channelID s previousState := channel.State channel.State = types.FLUSHCOMPLETE k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) } upgrade, found := k.GetUpgrade(ctx, portID, channelID) @@ -464,9 +461,7 @@ func (k *Keeper) ChanUpgradeConfirm( } timeout := counterpartyUpgrade.Timeout - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - selfHeight, selfTimestamp := clienttypes.GetSelfHeight(sdkCtx), uint64(sdkCtx.BlockTime().UnixNano()) - + selfHeight, selfTimestamp := clienttypes.GetSelfHeight(ctx), uint64(k.HeaderService.HeaderInfo(ctx).Time.UnixNano()) if timeout.Elapsed(selfHeight, selfTimestamp) { return types.NewUpgradeError(channel.UpgradeSequence, errorsmod.Wrap(timeout.ErrTimeoutElapsed(selfHeight, selfTimestamp), "counterparty upgrade timeout elapsed")) } @@ -490,7 +485,7 @@ func (k *Keeper) WriteUpgradeConfirmChannel(ctx context.Context, portID, channel previousState := channel.State channel.State = types.FLUSHCOMPLETE k.SetChannel(ctx, portID, channelID, channel) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", channel.State) } k.SetCounterpartyUpgrade(ctx, portID, channelID, counterpartyUpgrade) @@ -647,7 +642,7 @@ func (k *Keeper) WriteUpgradeOpenChannel(ctx context.Context, portID, channelID // delete state associated with upgrade which is no longer required. k.deleteUpgradeInfo(ctx, portID, channelID) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) return channel } @@ -725,7 +720,7 @@ func (k *Keeper) WriteUpgradeCancelChannel(ctx context.Context, portID, channelI channel = k.restoreChannel(ctx, portID, channelID, sequence, channel) k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(sequence, types.ErrInvalidUpgrade)) - k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) + k.Logger.Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.OPEN) } // ChanUpgradeTimeout times out an outstanding upgrade. @@ -845,7 +840,7 @@ func (k *Keeper) WriteUpgradeTimeoutChannel( channel = k.restoreChannel(ctx, portID, channelID, channel.UpgradeSequence, channel) k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(channel.UpgradeSequence, types.ErrUpgradeTimeout)) - k.Logger(ctx).Info("channel state restored", "port-id", portID, "channel-id", channelID) + k.Logger.Info("channel state restored", "port-id", portID, "channel-id", channelID) return channel, upgrade } @@ -885,8 +880,8 @@ func (k *Keeper) startFlushing(ctx context.Context, portID, channelID string, up // getAbsoluteUpgradeTimeout returns the absolute timeout for the given upgrade. func (k *Keeper) getAbsoluteUpgradeTimeout(ctx context.Context) types.Timeout { upgradeTimeout := k.GetParams(ctx).UpgradeTimeout - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 - return types.NewTimeout(clienttypes.ZeroHeight(), uint64(sdkCtx.BlockTime().UnixNano())+upgradeTimeout.Timestamp) + blockTime := k.HeaderService.HeaderInfo(ctx).Time.UnixNano() + return types.NewTimeout(clienttypes.ZeroHeight(), uint64(blockTime)+upgradeTimeout.Timestamp) } // checkForUpgradeCompatibility checks performs stateful validation of self upgrade fields relative to counterparty upgrade. @@ -1053,5 +1048,7 @@ func (k *Keeper) WriteErrorReceipt(ctx context.Context, portID, channelID string } k.setUpgradeErrorReceipt(ctx, portID, channelID, errorReceiptToWrite) - EmitErrorReceiptEvent(ctx, portID, channelID, channel, upgradeError) + if err := k.EmitErrorReceiptEvent(ctx, portID, channelID, channel, upgradeError); err != nil { + panic(err) + } } diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index a35288a48c1..cbf94750856 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -1,15 +1,9 @@ package keeper import ( - "context" "strings" - "cosmossdk.io/log" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" - "github.com/cosmos/ibc-go/v9/modules/core/exported" ) // Keeper defines the IBC connection keeper @@ -22,12 +16,6 @@ func NewKeeper() *Keeper { return &Keeper{} } -// Logger returns a module-specific logger. -func (Keeper) Logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"/"+types.SubModuleName) -} - // Route returns a IBCModule for a given module, and a boolean indicating // whether or not the route is present. func (k *Keeper) Route(module string) (types.IBCModule, bool) { diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index ccb1abe974d..9c9350071ec 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -5,7 +5,7 @@ import ( "reflect" "strings" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/codec" @@ -20,6 +20,8 @@ import ( // Keeper defines each ICS keeper for IBC type Keeper struct { + appmodule.Environment + ClientKeeper *clientkeeper.Keeper ConnectionKeeper *connectionkeeper.Keeper ChannelKeeper *channelkeeper.Keeper @@ -32,7 +34,7 @@ type Keeper struct { // NewKeeper creates a new ibc Keeper func NewKeeper( - cdc codec.BinaryCodec, storeService corestore.KVStoreService, paramSpace types.ParamSubspace, + cdc codec.BinaryCodec, env appmodule.Environment, paramSpace types.ParamSubspace, upgradeKeeper clienttypes.UpgradeKeeper, authority string, ) *Keeper { // panic if any of the keepers passed in is empty @@ -44,12 +46,13 @@ func NewKeeper( panic(errors.New("authority must be non-empty")) } - clientKeeper := clientkeeper.NewKeeper(cdc, storeService, paramSpace, upgradeKeeper) - connectionKeeper := connectionkeeper.NewKeeper(cdc, storeService, paramSpace, clientKeeper) + clientKeeper := clientkeeper.NewKeeper(cdc, env, paramSpace, upgradeKeeper) + connectionKeeper := connectionkeeper.NewKeeper(cdc, env, paramSpace, clientKeeper) portKeeper := portkeeper.NewKeeper() - channelKeeper := channelkeeper.NewKeeper(cdc, storeService, clientKeeper, connectionKeeper) + channelKeeper := channelkeeper.NewKeeper(cdc, env, clientKeeper, connectionKeeper) return &Keeper{ + Environment: env, cdc: cdc, ClientKeeper: clientKeeper, ConnectionKeeper: connectionKeeper, diff --git a/modules/core/keeper/keeper_test.go b/modules/core/keeper/keeper_test.go index 77d11f82c70..fa4e01238c3 100644 --- a/modules/core/keeper/keeper_test.go +++ b/modules/core/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" + "cosmossdk.io/log" upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/cosmos/cosmos-sdk/runtime" @@ -75,7 +76,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeperFn = func() { ibckeeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), + runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), log.NewNopLogger()), suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName), upgradeKeeper, "", // authority @@ -95,7 +96,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() { newIBCKeeperFn = func() { ibckeeper.NewKeeper( suite.chainA.GetSimApp().AppCodec(), - runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), + runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)), log.NewNopLogger()), suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName), upgradeKeeper, suite.chainA.App.GetIBCKeeper().GetAuthority(), diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b8dabeb8bb2..d6aac0335f2 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -10,7 +10,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v9/modules/core/04-channel/keeper" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" @@ -30,9 +29,7 @@ var ( // of the light client module to unmarshal and interpret the proto encoded bytes. // Backwards compatibility with older versions of ibc-go is maintained through the light client module reconstructing and encoding // the expected concrete type to the protobuf.Any for proof verification. -func (k *Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) CreateClient(ctx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error) { clientState, err := clienttypes.UnpackClientState(msg.ClientState) if err != nil { return nil, err @@ -47,9 +44,7 @@ func (k *Keeper) CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateC } // UpdateClient defines a rpc handler method for MsgUpdateClient. -func (k *Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) UpdateClient(ctx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error) { clientMsg, err := clienttypes.UnpackClientMessage(msg.ClientMessage) if err != nil { return nil, err @@ -68,11 +63,10 @@ func (k *Keeper) UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateC // of the light client module to unmarshal and interpret the proto encoded bytes. // Backwards compatibility with older versions of ibc-go is maintained through the light client module reconstructing and encoding // the expected concrete type to the protobuf.Any for proof verification. -func (k *Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgradeClient) (*clienttypes.MsgUpgradeClientResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) UpgradeClient(ctx context.Context, msg *clienttypes.MsgUpgradeClient) (*clienttypes.MsgUpgradeClientResponse, error) { if err := k.ClientKeeper.UpgradeClient( - ctx, msg.ClientId, + ctx, + msg.ClientId, msg.ClientState.Value, msg.ConsensusState.Value, msg.ProofUpgradeClient, @@ -87,9 +81,7 @@ func (k *Keeper) UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgrad // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. // Warning: DEPRECATED // This handler is redundant as `MsgUpdateClient` is now capable of handling both a Header and a Misbehaviour -func (k *Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) SubmitMisbehaviour(ctx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error) { //nolint:staticcheck // for now, we're using msgsubmitmisbehaviour. misbehaviour, err := clienttypes.UnpackClientMessage(msg.Misbehaviour) if err != nil { return nil, err @@ -103,12 +95,11 @@ func (k *Keeper) SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgS } // RecoverClient defines a rpc handler method for MsgRecoverClient. -func (k *Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecoverClient) (*clienttypes.MsgRecoverClientResponse, error) { +func (k *Keeper) RecoverClient(ctx context.Context, msg *clienttypes.MsgRecoverClient) (*clienttypes.MsgRecoverClientResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } - ctx := sdk.UnwrapSDKContext(goCtx) if err := k.ClientKeeper.RecoverClient(ctx, msg.SubjectClientId, msg.SubstituteClientId); err != nil { return nil, errorsmod.Wrap(err, "client recovery failed") } @@ -117,7 +108,7 @@ func (k *Keeper) RecoverClient(goCtx context.Context, msg *clienttypes.MsgRecove } // IBCSoftwareUpgrade defines a rpc handler method for MsgIBCSoftwareUpgrade. -func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgIBCSoftwareUpgrade) (*clienttypes.MsgIBCSoftwareUpgradeResponse, error) { +func (k *Keeper) IBCSoftwareUpgrade(ctx context.Context, msg *clienttypes.MsgIBCSoftwareUpgrade) (*clienttypes.MsgIBCSoftwareUpgradeResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } @@ -127,7 +118,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI return nil, errorsmod.Wrapf(clienttypes.ErrInvalidClientType, "cannot unpack client state: %s", err) } - if err := k.ClientKeeper.ScheduleIBCSoftwareUpgrade(goCtx, msg.Plan, upgradedClientState); err != nil { + if err := k.ClientKeeper.ScheduleIBCSoftwareUpgrade(ctx, msg.Plan, upgradedClientState); err != nil { return nil, errorsmod.Wrap(err, "failed to schedule upgrade") } @@ -135,9 +126,7 @@ func (k *Keeper) IBCSoftwareUpgrade(goCtx context.Context, msg *clienttypes.MsgI } // ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. -func (k *Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ConnectionOpenInit(ctx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error) { if _, err := k.ConnectionKeeper.ConnOpenInit(ctx, msg.ClientId, msg.Counterparty, msg.Version, msg.DelayPeriod); err != nil { return nil, errorsmod.Wrap(err, "connection handshake open init failed") } @@ -146,9 +135,7 @@ func (k *Keeper) ConnectionOpenInit(goCtx context.Context, msg *connectiontypes. } // ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. -func (k *Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenTry) (*connectiontypes.MsgConnectionOpenTryResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ConnectionOpenTry(ctx context.Context, msg *connectiontypes.MsgConnectionOpenTry) (*connectiontypes.MsgConnectionOpenTryResponse, error) { if _, err := k.ConnectionKeeper.ConnOpenTry( ctx, msg.Counterparty, msg.DelayPeriod, msg.ClientId, msg.CounterpartyVersions, msg.ProofInit, msg.ProofHeight, @@ -160,9 +147,7 @@ func (k *Keeper) ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.M } // ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. -func (k *Keeper) ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenAck) (*connectiontypes.MsgConnectionOpenAckResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ConnectionOpenAck(ctx context.Context, msg *connectiontypes.MsgConnectionOpenAck) (*connectiontypes.MsgConnectionOpenAckResponse, error) { if err := k.ConnectionKeeper.ConnOpenAck( ctx, msg.ConnectionId, msg.Version, msg.CounterpartyConnectionId, msg.ProofTry, msg.ProofHeight, @@ -174,9 +159,7 @@ func (k *Keeper) ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.M } // ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. -func (k *Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenConfirm) (*connectiontypes.MsgConnectionOpenConfirmResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ConnectionOpenConfirm(ctx context.Context, msg *connectiontypes.MsgConnectionOpenConfirm) (*connectiontypes.MsgConnectionOpenConfirmResponse, error) { if err := k.ConnectionKeeper.ConnOpenConfirm( ctx, msg.ConnectionId, msg.ProofAck, msg.ProofHeight, ); err != nil { @@ -189,13 +172,11 @@ func (k *Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontyp // ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. // ChannelOpenInit will perform 04-channel checks, route to the application // callback, and write an OpenInit channel into state upon successful execution. -func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelOpenInit(ctx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, error) { // Retrieve application callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel open init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel open init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } @@ -204,21 +185,21 @@ func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgCha ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, msg.Channel.Counterparty, msg.Channel.Version, ) if err != nil { - ctx.Logger().Error("channel open init failed", "error", errorsmod.Wrap(err, "channel handshake open init failed")) + k.Logger.Error("channel open init failed", "error", errorsmod.Wrap(err, "channel handshake open init failed")) return nil, errorsmod.Wrap(err, "channel handshake open init failed") } // Perform application logic callback version, err := cbs.OnChanOpenInit(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, msg.Channel.Counterparty, msg.Channel.Version) if err != nil { - ctx.Logger().Error("channel open init failed", "port-id", msg.PortId, "channel-id", channelID, "error", errorsmod.Wrap(err, "channel open init callback failed")) + k.Logger.Error("channel open init failed", "port-id", msg.PortId, "channel-id", channelID, "error", errorsmod.Wrap(err, "channel open init callback failed")) return nil, errorsmod.Wrapf(err, "channel open init callback failed for port ID: %s, channel ID: %s", msg.PortId, channelID) } // Write channel into state k.ChannelKeeper.WriteOpenInitChannel(ctx, msg.PortId, channelID, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.Channel.Counterparty, version) - ctx.Logger().Info("channel open init succeeded", "channel-id", channelID, "version", version) + k.Logger.Info("channel open init succeeded", "channel-id", channelID, "version", version) return &channeltypes.MsgChannelOpenInitResponse{ ChannelId: channelID, @@ -229,34 +210,32 @@ func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgCha // ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. // ChannelOpenTry will perform 04-channel checks, route to the application // callback, and write an OpenTry channel into state upon successful execution. -func (k *Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChannelOpenTry) (*channeltypes.MsgChannelOpenTryResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelOpenTry(ctx context.Context, msg *channeltypes.MsgChannelOpenTry) (*channeltypes.MsgChannelOpenTryResponse, error) { // Retrieve application callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel open try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel open try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } // Perform 04-channel verification channelID, err := k.ChannelKeeper.ChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, msg.Channel.Counterparty, msg.CounterpartyVersion, msg.ProofInit, msg.ProofHeight) if err != nil { - ctx.Logger().Error("channel open try failed", "error", errorsmod.Wrap(err, "channel handshake open try failed")) + k.Logger.Error("channel open try failed", "error", errorsmod.Wrap(err, "channel handshake open try failed")) return nil, errorsmod.Wrap(err, "channel handshake open try failed") } // Perform application logic callback version, err := cbs.OnChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, msg.Channel.Counterparty, msg.CounterpartyVersion) if err != nil { - ctx.Logger().Error("channel open try failed", "port-id", msg.PortId, "channel-id", channelID, "error", errorsmod.Wrap(err, "channel open try callback failed")) + k.Logger.Error("channel open try failed", "port-id", msg.PortId, "channel-id", channelID, "error", errorsmod.Wrap(err, "channel open try callback failed")) return nil, errorsmod.Wrapf(err, "channel open try callback failed for port ID: %s, channel ID: %s", msg.PortId, channelID) } // Write channel into state k.ChannelKeeper.WriteOpenTryChannel(ctx, msg.PortId, channelID, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.Channel.Counterparty, version) - ctx.Logger().Info("channel open try succeeded", "channel-id", channelID, "port-id", msg.PortId, "version", version) + k.Logger.Info("channel open try succeeded", "channel-id", channelID, "port-id", msg.PortId, "version", version) return &channeltypes.MsgChannelOpenTryResponse{ ChannelId: channelID, @@ -267,13 +246,11 @@ func (k *Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChan // ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. // ChannelOpenAck will perform 04-channel checks, route to the application // callback, and write an OpenAck channel into state upon successful execution. -func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChannelOpenAck) (*channeltypes.MsgChannelOpenAckResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelOpenAck(ctx context.Context, msg *channeltypes.MsgChannelOpenAck) (*channeltypes.MsgChannelOpenAckResponse, error) { // Retrieve application callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel open ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel open ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } @@ -281,7 +258,7 @@ func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChan if err := k.ChannelKeeper.ChanOpenAck( ctx, msg.PortId, msg.ChannelId, msg.CounterpartyVersion, msg.CounterpartyChannelId, msg.ProofTry, msg.ProofHeight, ); err != nil { - ctx.Logger().Error("channel open ack failed", "error", err.Error()) + k.Logger.Error("channel open ack failed", "error", err.Error()) return nil, errorsmod.Wrap(err, "channel handshake open ack failed") } @@ -290,11 +267,11 @@ func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChan // Perform application logic callback if err := cbs.OnChanOpenAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelId, msg.CounterpartyVersion); err != nil { - ctx.Logger().Error("channel open ack failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel open ack callback failed")) + k.Logger.Error("channel open ack failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel open ack callback failed")) return nil, errorsmod.Wrapf(err, "channel open ack callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } - ctx.Logger().Info("channel open ack succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) + k.Logger.Info("channel open ack succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) return &channeltypes.MsgChannelOpenAckResponse{}, nil } @@ -302,19 +279,17 @@ func (k *Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChan // ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. // ChannelOpenConfirm will perform 04-channel checks, route to the application // callback, and write an OpenConfirm channel into state upon successful execution. -func (k *Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgChannelOpenConfirm) (*channeltypes.MsgChannelOpenConfirmResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelOpenConfirm(ctx context.Context, msg *channeltypes.MsgChannelOpenConfirm) (*channeltypes.MsgChannelOpenConfirmResponse, error) { // Retrieve application callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel open confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel open confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } // Perform 04-channel verification if err := k.ChannelKeeper.ChanOpenConfirm(ctx, msg.PortId, msg.ChannelId, msg.ProofAck, msg.ProofHeight); err != nil { - ctx.Logger().Error("channel open confirm failed", "error", errorsmod.Wrap(err, "channel handshake open confirm failed")) + k.Logger.Error("channel open confirm failed", "error", errorsmod.Wrap(err, "channel handshake open confirm failed")) return nil, errorsmod.Wrap(err, "channel handshake open confirm failed") } @@ -323,65 +298,61 @@ func (k *Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.Msg // Perform application logic callback if err := cbs.OnChanOpenConfirm(ctx, msg.PortId, msg.ChannelId); err != nil { - ctx.Logger().Error("channel open confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel open confirm callback failed")) + k.Logger.Error("channel open confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel open confirm callback failed")) return nil, errorsmod.Wrapf(err, "channel open confirm callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } - ctx.Logger().Info("channel open confirm succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) + k.Logger.Info("channel open confirm succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) return &channeltypes.MsgChannelOpenConfirmResponse{}, nil } // ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. -func (k *Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgChannelCloseInit) (*channeltypes.MsgChannelCloseInitResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelCloseInit(ctx context.Context, msg *channeltypes.MsgChannelCloseInit) (*channeltypes.MsgChannelCloseInitResponse, error) { // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel close init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } if err := cbs.OnChanCloseInit(ctx, msg.PortId, msg.ChannelId); err != nil { - ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel close init callback failed")) + k.Logger.Error("channel close init failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel close init callback failed")) return nil, errorsmod.Wrapf(err, "channel close init callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } err := k.ChannelKeeper.ChanCloseInit(ctx, msg.PortId, msg.ChannelId) if err != nil { - ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + k.Logger.Error("channel close init failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, errorsmod.Wrap(err, "channel handshake close init failed") } - ctx.Logger().Info("channel close init succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) + k.Logger.Info("channel close init succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) return &channeltypes.MsgChannelCloseInitResponse{}, nil } // ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. -func (k *Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.MsgChannelCloseConfirm) (*channeltypes.MsgChannelCloseConfirmResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelCloseConfirm(ctx context.Context, msg *channeltypes.MsgChannelCloseConfirm) (*channeltypes.MsgChannelCloseConfirmResponse, error) { // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel close confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } if err := cbs.OnChanCloseConfirm(ctx, msg.PortId, msg.ChannelId); err != nil { - ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel close confirm callback failed")) + k.Logger.Error("channel close confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", errorsmod.Wrap(err, "channel close confirm callback failed")) return nil, errorsmod.Wrapf(err, "channel close confirm callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } err := k.ChannelKeeper.ChanCloseConfirm(ctx, msg.PortId, msg.ChannelId, msg.ProofInit, msg.ProofHeight, msg.CounterpartyUpgradeSequence) if err != nil { - ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + k.Logger.Error("channel close confirm failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, errorsmod.Wrap(err, "channel handshake close confirm failed") } - ctx.Logger().Info("channel close confirm succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) + k.Logger.Info("channel close confirm succeeded", "channel-id", msg.ChannelId, "port-id", msg.PortId) return &channeltypes.MsgChannelCloseConfirmResponse{}, nil } @@ -392,14 +363,14 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack relayer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { - ctx.Logger().Error("receive packet failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + k.Logger.Error("receive packet failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.Packet.DestinationPort) if !ok { - ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.DestinationPort)) + k.Logger.Error("receive packet failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.DestinationPort)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.DestinationPort) } @@ -415,10 +386,10 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack writeFn() case channeltypes.ErrNoOpMsg: // no-ops do not need event emission as they will be ignored - ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) + k.Logger.Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.NOOP}, nil default: - ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) + k.Logger.Error("receive packet failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "receive packet verification failed")) return nil, errorsmod.Wrap(err, "receive packet verification failed") } @@ -446,44 +417,46 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack defer telemetry.ReportRecvPacket(msg.Packet) - ctx.Logger().Info("receive packet callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) + k.Logger.Info("receive packet callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.SUCCESS}, nil } // Timeout defines a rpc handler method for MsgTimeout. -func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) Timeout(ctx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { relayer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { - ctx.Logger().Error("timeout failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + k.Logger.Error("timeout failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } // Retrieve callbacks from router cbs, ok := k.PortKeeper.Route(msg.Packet.SourcePort) if !ok { - ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) + k.Logger.Error("timeout failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort) } - // Perform TAO verification - // - // If the timeout was already received, perform a no-op - // Use a cached context to prevent accidental state changes - cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.TimeoutPacket(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) + var channelVersion string + if err := k.BranchService.Execute(ctx, func(ctx context.Context) error { + // Perform TAO verification + // + // If the timeout was already received, perform a no-op + // Use a branched multistore to prevent accidental state changes + channelVersion, err = k.ChannelKeeper.TimeoutPacket(ctx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv) + if err != nil { + return err + } - switch err { - case nil: - writeFn() - case channeltypes.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored - ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) - return &channeltypes.MsgTimeoutResponse{Result: channeltypes.NOOP}, nil - default: - ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) + return nil + }); err != nil { + if errors.Is(err, channeltypes.ErrNoOpMsg) { + // no-ops do not need event emission as they will be ignored + k.Logger.Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) + return &channeltypes.MsgTimeoutResponse{Result: channeltypes.NOOP}, nil + } + + k.Logger.Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet verification failed")) return nil, errorsmod.Wrap(err, "timeout packet verification failed") } @@ -492,52 +465,55 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (* return nil, err } - // Perform application logic callback - err = cbs.OnTimeoutPacket(ctx, channelVersion, msg.Packet, relayer) - if err != nil { - ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet callback failed")) + if err := k.BranchService.Execute(ctx, func(ctx context.Context) error { + // Perform application logic callback + return cbs.OnTimeoutPacket(ctx, channelVersion, msg.Packet, relayer) + }); err != nil { + k.Logger.Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout packet callback failed")) return nil, errorsmod.Wrap(err, "timeout packet callback failed") } defer telemetry.ReportTimeoutPacket(msg.Packet, "height") - ctx.Logger().Info("timeout packet callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) + k.Logger.Info("timeout packet callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) return &channeltypes.MsgTimeoutResponse{Result: channeltypes.SUCCESS}, nil } // TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. -func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) TimeoutOnClose(ctx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error) { relayer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { - ctx.Logger().Error("timeout on close failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + k.Logger.Error("timeout on close failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } cbs, ok := k.PortKeeper.Route(msg.Packet.SourcePort) if !ok { - ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) + k.Logger.Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort) } - // Perform TAO verification - // - // If the timeout was already received, perform a no-op - // Use a cached context to prevent accidental state changes - cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.TimeoutOnClose(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv, msg.CounterpartyUpgradeSequence) + var channelVersion string + if err := k.BranchService.Execute(ctx, func(ctx context.Context) error { + // Perform TAO verification + // + // If the timeout was already received, perform a no-op + // Use a branched multistore to prevent accidental state changes + channelVersion, err = k.ChannelKeeper.TimeoutOnClose(ctx, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv, msg.CounterpartyUpgradeSequence) + if err != nil { + return err + } - switch err { - case nil: - writeFn() - case channeltypes.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored - ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) - return &channeltypes.MsgTimeoutOnCloseResponse{Result: channeltypes.NOOP}, nil - default: - ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout on close packet verification failed")) + return nil + }); err != nil { + if errors.Is(err, channeltypes.ErrNoOpMsg) { + // no-ops do not need event emission as they will be ignored + k.Logger.Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) + return &channeltypes.MsgTimeoutOnCloseResponse{Result: channeltypes.NOOP}, nil + } + + k.Logger.Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout on close packet verification failed")) return nil, errorsmod.Wrap(err, "timeout on close packet verification failed") } @@ -552,62 +528,64 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime // application logic callback. err = cbs.OnTimeoutPacket(ctx, channelVersion, msg.Packet, relayer) if err != nil { - ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout on close callback failed")) + k.Logger.Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "timeout on close callback failed")) return nil, errorsmod.Wrap(err, "timeout on close callback failed") } defer telemetry.ReportTimeoutPacket(msg.Packet, "channel-closed") - ctx.Logger().Info("timeout on close callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) + k.Logger.Info("timeout on close callback succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) return &channeltypes.MsgTimeoutOnCloseResponse{Result: channeltypes.SUCCESS}, nil } // Acknowledgement defines a rpc handler method for MsgAcknowledgement. -func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) Acknowledgement(ctx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { relayer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { - ctx.Logger().Error("acknowledgement failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) + k.Logger.Error("acknowledgement failed", "error", errorsmod.Wrap(err, "Invalid address for msg Signer")) return nil, errorsmod.Wrap(err, "Invalid address for msg Signer") } cbs, ok := k.PortKeeper.Route(msg.Packet.SourcePort) if !ok { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) + k.Logger.Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.Packet.SourcePort) } - // Perform TAO verification - // - // If the acknowledgement was already received, perform a no-op - // Use a cached context to prevent accidental state changes - cacheCtx, writeFn := ctx.CacheContext() - channelVersion, err := k.ChannelKeeper.AcknowledgePacket(cacheCtx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + var channelVersion string + if err := k.BranchService.Execute(ctx, func(ctx context.Context) error { + // Perform TAO verification + // + // If the acknowledgement was already received, perform a no-op + // Use a branched multistore to prevent accidental state changes + channelVersion, err = k.ChannelKeeper.AcknowledgePacket(ctx, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + if err != nil { + return err + } - switch err { - case nil: - writeFn() - case channeltypes.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored - ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) - return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.NOOP}, nil - default: - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) + return nil + }); err != nil { + if errors.Is(err, channeltypes.ErrNoOpMsg) { + // no-ops do not need event emission as they will be ignored + k.Logger.Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel) + return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.NOOP}, nil + } + + k.Logger.Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet verification failed")) return nil, errorsmod.Wrap(err, "acknowledge packet verification failed") } // Perform application logic callback err = cbs.OnAcknowledgementPacket(ctx, channelVersion, msg.Packet, msg.Acknowledgement, relayer) if err != nil { - ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet callback failed")) + k.Logger.Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", errorsmod.Wrap(err, "acknowledge packet callback failed")) return nil, errorsmod.Wrap(err, "acknowledge packet callback failed") } defer telemetry.ReportAcknowledgePacket(msg.Packet) - ctx.Logger().Info("acknowledgement succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) + k.Logger.Info("acknowledgement succeeded", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "result", channeltypes.SUCCESS.String()) return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.SUCCESS}, nil } @@ -622,19 +600,19 @@ func (k *Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.Msg app, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } cbs, ok := app.(porttypes.UpgradableModule) if !ok { - ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) } upgrade, err := k.ChannelKeeper.ChanUpgradeInit(ctx, msg.PortId, msg.ChannelId, msg.Fields) if err != nil { - ctx.Logger().Error("channel upgrade init failed", "error", errorsmod.Wrap(err, "channel upgrade init failed")) + k.Logger.Error("channel upgrade init failed", "error", errorsmod.Wrap(err, "channel upgrade init failed")) return nil, errorsmod.Wrap(err, "channel upgrade init failed") } @@ -643,14 +621,16 @@ func (k *Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.Msg cacheCtx, _ := ctx.CacheContext() upgradeVersion, err := cbs.OnChanUpgradeInit(cacheCtx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) if err != nil { - ctx.Logger().Error("channel upgrade init callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + k.Logger.Error("channel upgrade init callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, errorsmod.Wrapf(err, "channel upgrade init callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } channel, upgrade := k.ChannelKeeper.WriteUpgradeInitChannel(ctx, msg.PortId, msg.ChannelId, upgrade, upgradeVersion) - ctx.Logger().Info("channel upgrade init succeeded", "channel-id", msg.ChannelId, "version", upgradeVersion) - keeper.EmitChannelUpgradeInitEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + k.Logger.Info("channel upgrade init succeeded", "channel-id", msg.ChannelId, "version", upgradeVersion) + if err := k.ChannelKeeper.EmitChannelUpgradeInitEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeInitResponse{ Upgrade: upgrade, @@ -664,19 +644,19 @@ func (k *Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgC app, ok := k.PortKeeper.Route(msg.PortId) if !ok { - ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) } cbs, ok := app.(porttypes.UpgradableModule) if !ok { - ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) + k.Logger.Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId)) return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) } channel, upgrade, err := k.ChannelKeeper.ChanUpgradeTry(ctx, msg.PortId, msg.ChannelId, msg.ProposedUpgradeConnectionHops, msg.CounterpartyUpgradeFields, msg.CounterpartyUpgradeSequence, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) if err != nil { - ctx.Logger().Error("channel upgrade try failed", "error", errorsmod.Wrap(err, "channel upgrade try failed")) + k.Logger.Error("channel upgrade try failed", "error", errorsmod.Wrap(err, "channel upgrade try failed")) if channeltypes.IsUpgradeError(err) { // In case the error is a wrapped upgrade error, we need to extract the inner error else process as normal var upgradeErr *channeltypes.UpgradeError @@ -697,14 +677,16 @@ func (k *Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgC cacheCtx, _ := ctx.CacheContext() upgradeVersion, err := cbs.OnChanUpgradeTry(cacheCtx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) if err != nil { - ctx.Logger().Error("channel upgrade try callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + k.Logger.Error("channel upgrade try callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, errorsmod.Wrapf(err, "channel upgrade try callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } channel, upgrade = k.ChannelKeeper.WriteUpgradeTryChannel(ctx, msg.PortId, msg.ChannelId, upgrade, upgradeVersion) - ctx.Logger().Info("channel upgrade try succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeTryEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + k.Logger.Info("channel upgrade try succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeTryEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeTryResponse{ Result: channeltypes.SUCCESS, @@ -720,20 +702,20 @@ func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgC app, ok := k.PortKeeper.Route(msg.PortId) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) return nil, err } cbs, ok := app.(porttypes.UpgradableModule) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err) return nil, err } err := k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) if err != nil { - ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel upgrade ack failed")) + k.Logger.Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel upgrade ack failed")) if channeltypes.IsUpgradeError(err) { k.ChannelKeeper.MustAbortUpgrade(ctx, msg.PortId, msg.ChannelId, err) @@ -756,7 +738,7 @@ func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgC return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) } - ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + k.Logger.Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) // explicitly wrap the application callback in an upgrade error with the correct upgrade sequence. // this prevents any errors caused from the application returning an UpgradeError with an incorrect sequence. @@ -767,33 +749,33 @@ func (k *Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgC channel, upgrade := k.ChannelKeeper.WriteUpgradeAckChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade) - ctx.Logger().Info("channel upgrade ack succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeAckEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + k.Logger.Info("channel upgrade ack succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeAckEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.SUCCESS}, nil } // ChannelUpgradeConfirm defines a rpc handler method for MsgChannelUpgradeConfirm. -func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeConfirm) (*channeltypes.MsgChannelUpgradeConfirmResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelUpgradeConfirm(ctx context.Context, msg *channeltypes.MsgChannelUpgradeConfirm) (*channeltypes.MsgChannelUpgradeConfirmResponse, error) { app, ok := k.PortKeeper.Route(msg.PortId) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) return nil, err } cbs, ok := app.(porttypes.UpgradableModule) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err) return nil, err } err := k.ChannelKeeper.ChanUpgradeConfirm(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) if err != nil { - ctx.Logger().Error("channel upgrade confirm failed", "error", errorsmod.Wrap(err, "channel upgrade confirm failed")) + k.Logger.Error("channel upgrade confirm failed", "error", errorsmod.Wrap(err, "channel upgrade confirm failed")) if channeltypes.IsUpgradeError(err) { k.ChannelKeeper.MustAbortUpgrade(ctx, msg.PortId, msg.ChannelId, err) @@ -807,8 +789,10 @@ func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes. } channel := k.ChannelKeeper.WriteUpgradeConfirmChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade) - ctx.Logger().Info("channel upgrade confirm succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeConfirmEvent(ctx, msg.PortId, msg.ChannelId, channel) + k.Logger.Info("channel upgrade confirm succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeConfirmEvent(ctx, msg.PortId, msg.ChannelId, channel); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } // Move channel to OPEN state if both chains have finished flushing in-flight packets. // Counterparty channel state has been verified in ChanUpgradeConfirm. @@ -821,33 +805,33 @@ func (k *Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes. cbs.OnChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) channel := k.ChannelKeeper.WriteUpgradeOpenChannel(ctx, msg.PortId, msg.ChannelId) - ctx.Logger().Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel) + k.Logger.Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } } return &channeltypes.MsgChannelUpgradeConfirmResponse{Result: channeltypes.SUCCESS}, nil } // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. -func (k *Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeOpen) (*channeltypes.MsgChannelUpgradeOpenResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelUpgradeOpen(ctx context.Context, msg *channeltypes.MsgChannelUpgradeOpen) (*channeltypes.MsgChannelUpgradeOpenResponse, error) { app, ok := k.PortKeeper.Route(msg.PortId) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) return nil, err } cbs, ok := app.(porttypes.UpgradableModule) if !ok { err := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to portID: %s", msg.PortId) - ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) + k.Logger.Error("channel upgrade open failed", "port-id", msg.PortId, "error", err) return nil, err } if err := k.ChannelKeeper.ChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.CounterpartyUpgradeSequence, msg.ProofChannel, msg.ProofHeight); err != nil { - ctx.Logger().Error("channel upgrade open failed", "error", errorsmod.Wrap(err, "channel upgrade open failed")) + k.Logger.Error("channel upgrade open failed", "error", errorsmod.Wrap(err, "channel upgrade open failed")) return nil, errorsmod.Wrap(err, "channel upgrade open failed") } @@ -859,32 +843,32 @@ func (k *Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.Msg cbs.OnChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, upgrade.Fields.Ordering, upgrade.Fields.ConnectionHops, upgrade.Fields.Version) channel := k.ChannelKeeper.WriteUpgradeOpenChannel(ctx, msg.PortId, msg.ChannelId) - ctx.Logger().Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel) + k.Logger.Info("channel upgrade open succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeOpenEvent(ctx, msg.PortId, msg.ChannelId, channel); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeOpenResponse{}, nil } // ChannelUpgradeTimeout defines a rpc handler method for MsgChannelUpgradeTimeout. -func (k *Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTimeout) (*channeltypes.MsgChannelUpgradeTimeoutResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelUpgradeTimeout(ctx context.Context, msg *channeltypes.MsgChannelUpgradeTimeout) (*channeltypes.MsgChannelUpgradeTimeoutResponse, error) { if err := k.ChannelKeeper.ChanUpgradeTimeout(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel, msg.ProofChannel, msg.ProofHeight); err != nil { return nil, errorsmod.Wrapf(err, "could not timeout upgrade for channel: %s", msg.ChannelId) } channel, upgrade := k.ChannelKeeper.WriteUpgradeTimeoutChannel(ctx, msg.PortId, msg.ChannelId) - ctx.Logger().Info("channel upgrade timeout callback succeeded: portID %s, channelID %s", msg.PortId, msg.ChannelId) - keeper.EmitChannelUpgradeTimeoutEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + k.Logger.Info("channel upgrade timeout callback succeeded: portID %s, channelID %s", msg.PortId, msg.ChannelId) + if err := k.ChannelKeeper.EmitChannelUpgradeTimeoutEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeTimeoutResponse{}, nil } // ChannelUpgradeCancel defines a rpc handler method for MsgChannelUpgradeCancel. -func (k *Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeCancel) (*channeltypes.MsgChannelUpgradeCancelResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) ChannelUpgradeCancel(ctx context.Context, msg *channeltypes.MsgChannelUpgradeCancel) (*channeltypes.MsgChannelUpgradeCancelResponse, error) { channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) if !found { return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) @@ -901,15 +885,17 @@ func (k *Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.M k.ChannelKeeper.WriteUpgradeCancelChannel(ctx, msg.PortId, msg.ChannelId, channel.UpgradeSequence) - ctx.Logger().Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + k.Logger.Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) - keeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + if err := k.ChannelKeeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeCancelResponse{}, nil } if err := k.ChannelKeeper.ChanUpgradeCancel(ctx, msg.PortId, msg.ChannelId, msg.ErrorReceipt, msg.ProofErrorReceipt, msg.ProofHeight); err != nil { - ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, "error", err.Error()) + k.Logger.Error("channel upgrade cancel failed", "port-id", msg.PortId, "error", err.Error()) return nil, errorsmod.Wrap(err, "channel upgrade cancel failed") } @@ -921,22 +907,23 @@ func (k *Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.M k.ChannelKeeper.WriteUpgradeCancelChannel(ctx, msg.PortId, msg.ChannelId, msg.ErrorReceipt.Sequence) - ctx.Logger().Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + k.Logger.Info("channel upgrade cancel succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) // get channel here again to get latest state after write channel, found = k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId) if !found { return nil, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.PortId, msg.ChannelId) } - keeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade) + + if err := k.ChannelKeeper.EmitChannelUpgradeCancelEvent(ctx, msg.PortId, msg.ChannelId, channel, upgrade); err != nil { + return nil, errorsmod.Wrap(err, "event emission failed") + } return &channeltypes.MsgChannelUpgradeCancelResponse{}, nil } // PruneAcknowledgements defines a rpc handler method for MsgPruneAcknowledgements. -func (k *Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes.MsgPruneAcknowledgements) (*channeltypes.MsgPruneAcknowledgementsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k *Keeper) PruneAcknowledgements(ctx context.Context, msg *channeltypes.MsgPruneAcknowledgements) (*channeltypes.MsgPruneAcknowledgementsResponse, error) { pruned, remaining, err := k.ChannelKeeper.PruneAcknowledgements(ctx, msg.PortId, msg.ChannelId, msg.Limit) if err != nil { return nil, err @@ -949,36 +936,33 @@ func (k *Keeper) PruneAcknowledgements(goCtx context.Context, msg *channeltypes. } // UpdateClientParams defines a rpc handler method for MsgUpdateParams. -func (k *Keeper) UpdateClientParams(goCtx context.Context, msg *clienttypes.MsgUpdateParams) (*clienttypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateClientParams(ctx context.Context, msg *clienttypes.MsgUpdateParams) (*clienttypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } - ctx := sdk.UnwrapSDKContext(goCtx) k.ClientKeeper.SetParams(ctx, msg.Params) return &clienttypes.MsgUpdateParamsResponse{}, nil } // UpdateConnectionParams defines a rpc handler method for MsgUpdateParams for the 03-connection submodule. -func (k *Keeper) UpdateConnectionParams(goCtx context.Context, msg *connectiontypes.MsgUpdateParams) (*connectiontypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateConnectionParams(ctx context.Context, msg *connectiontypes.MsgUpdateParams) (*connectiontypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer) } - ctx := sdk.UnwrapSDKContext(goCtx) k.ConnectionKeeper.SetParams(ctx, msg.Params) return &connectiontypes.MsgUpdateParamsResponse{}, nil } // UpdateChannelParams defines a rpc handler method for MsgUpdateParams. -func (k *Keeper) UpdateChannelParams(goCtx context.Context, msg *channeltypes.MsgUpdateParams) (*channeltypes.MsgUpdateParamsResponse, error) { +func (k *Keeper) UpdateChannelParams(ctx context.Context, msg *channeltypes.MsgUpdateParams) (*channeltypes.MsgUpdateParamsResponse, error) { if k.GetAuthority() != msg.Authority { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) } - ctx := sdk.UnwrapSDKContext(goCtx) k.ChannelKeeper.SetParams(ctx, msg.Params) return &channeltypes.MsgUpdateParamsResponse{}, nil diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 205282687dd..d9cbff138a4 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1005,12 +1005,13 @@ func (suite *KeeperTestSuite) TestChannelUpgradeInit() { ) suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeInit = func(ctx context.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string) (string, error) { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - store := sdkCtx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) + store := suite.chainA.GetSimApp().GetIBCKeeper().KVStoreService.OpenKVStore(ctx) + err := store.Set(ibcmock.TestKey, ibcmock.TestValue) + suite.Require().NoError(err) - sdkCtx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) + eventService := suite.chainA.GetSimApp().GetIBCKeeper().EventService + err = eventService.EventManager(ctx).EmitKV(ibcmock.MockEventType) + suite.Require().NoError(err) return ibcmock.UpgradeVersion, nil } }, @@ -1153,12 +1154,13 @@ func (suite *KeeperTestSuite) TestChannelUpgradeTry() { "ibc application does not commit state changes in callback", func() { suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeTry = func(ctx context.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, counterpartyVersion string) (string, error) { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - store := sdkCtx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) + store := suite.chainA.GetSimApp().GetIBCKeeper().KVStoreService.OpenKVStore(ctx) + err := store.Set(ibcmock.TestKey, ibcmock.TestValue) + suite.Require().NoError(err) - sdkCtx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) + eventService := suite.chainA.GetSimApp().GetIBCKeeper().EventService + err = eventService.EventManager(ctx).EmitKV(ibcmock.MockEventType) + suite.Require().NoError(err) return ibcmock.UpgradeVersion, nil } }, @@ -1361,9 +1363,9 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { ctx context.Context, portID, channelID, counterpartyVersion string, ) error { // set arbitrary value in store to mock application state changes - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - store := sdkCtx.KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) - store.Set([]byte("foo"), []byte("bar")) + store := suite.chainA.GetSimApp().GetIBCKeeper().KVStoreService.OpenKVStore(ctx) + err := store.Set(ibcmock.TestKey, ibcmock.TestValue) + suite.Require().NoError(err) return fmt.Errorf("mock app callback failed") } }, @@ -1435,12 +1437,13 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { "ibc application does not commit state changes in callback", func() { suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func(ctx context.Context, portID, channelID, counterpartyVersion string) error { - storeKey := suite.chainA.GetSimApp().GetKey(exported.ModuleName) - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - store := sdkCtx.KVStore(storeKey) - store.Set(ibcmock.TestKey, ibcmock.TestValue) + store := suite.chainA.GetSimApp().GetIBCKeeper().KVStoreService.OpenKVStore(ctx) + err := store.Set(ibcmock.TestKey, ibcmock.TestValue) + suite.Require().NoError(err) - sdkCtx.EventManager().EmitEvent(sdk.NewEvent(ibcmock.MockEventType)) + eventService := suite.chainA.GetSimApp().GetIBCKeeper().EventService + err = eventService.EventManager(ctx).EmitKV(ibcmock.MockEventType) + suite.Require().NoError(err) return nil } }, diff --git a/modules/core/module.go b/modules/core/module.go index 04cde49d313..7f350ed69b6 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -182,7 +182,7 @@ func (AppModule) ConsensusVersion() uint64 { return 7 } // BeginBlock returns the begin blocker for the ibc module. func (am AppModule) BeginBlock(ctx context.Context) error { - ibcclient.BeginBlocker(sdk.UnwrapSDKContext(ctx), am.keeper.ClientKeeper) + ibcclient.BeginBlocker(ctx, am.keeper.ClientKeeper) return nil } diff --git a/modules/light-clients/07-tendermint/migrations/expected_keepers.go b/modules/light-clients/07-tendermint/migrations/expected_keepers.go index 48ff97e416d..b56b5c4171f 100644 --- a/modules/light-clients/07-tendermint/migrations/expected_keepers.go +++ b/modules/light-clients/07-tendermint/migrations/expected_keepers.go @@ -3,7 +3,6 @@ package migrations import ( "context" - "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -14,5 +13,4 @@ type ClientKeeper interface { GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool) IterateClientStates(ctx context.Context, prefix []byte, cb func(string, exported.ClientState) bool) ClientStore(ctx context.Context, clientID string) storetypes.KVStore - Logger(ctx context.Context) log.Logger } diff --git a/modules/light-clients/07-tendermint/migrations/migrations.go b/modules/light-clients/07-tendermint/migrations/migrations.go index c5457f6e684..c5705f7a90c 100644 --- a/modules/light-clients/07-tendermint/migrations/migrations.go +++ b/modules/light-clients/07-tendermint/migrations/migrations.go @@ -6,6 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -41,7 +42,7 @@ func PruneExpiredConsensusStates(ctx context.Context, cdc codec.BinaryCodec, cli totalPruned += ibctm.PruneAllExpiredConsensusStates(ctx, clientStore, cdc, tmClientState) } - clientKeeper.Logger(ctx).Info("pruned expired tendermint consensus states", "total", totalPruned) + sdk.UnwrapSDKContext(ctx).Logger().Info("pruned expired tendermint consensus states", "total", totalPruned) return totalPruned, nil } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 360f7f91077..9e3022605c7 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -470,7 +470,11 @@ func NewSimApp( app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper) app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")), + app.GetSubspace(ibcexported.ModuleName), + app.UpgradeKeeper, + govModuleAddr, ) govRouter := govv1beta1.NewRouter() diff --git a/modules/light-clients/09-localhost/light_client_module.go b/modules/light-clients/09-localhost/light_client_module.go index d18cbce8eef..cadfa805896 100644 --- a/modules/light-clients/09-localhost/light_client_module.go +++ b/modules/light-clients/09-localhost/light_client_module.go @@ -4,7 +4,7 @@ import ( "bytes" "context" - corestore "cosmossdk.io/core/store" + "cosmossdk.io/core/appmodule" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" @@ -33,15 +33,15 @@ var _ exported.LightClientModule = (*LightClientModule)(nil) // LightClientModule implements the core IBC api.LightClientModule interface. type LightClientModule struct { - cdc codec.BinaryCodec - storeService corestore.KVStoreService + cdc codec.BinaryCodec + appmodule.Environment } // NewLightClientModule creates and returns a new 09-localhost LightClientModule. -func NewLightClientModule(cdc codec.BinaryCodec, storeService corestore.KVStoreService) *LightClientModule { +func NewLightClientModule(cdc codec.BinaryCodec, env appmodule.Environment) *LightClientModule { return &LightClientModule{ - cdc: cdc, - storeService: storeService, + cdc: cdc, + Environment: env, } } @@ -83,7 +83,7 @@ func (l LightClientModule) VerifyMembership( path exported.Path, value []byte, ) error { - ibcStore := l.storeService.OpenKVStore(ctx) + ibcStore := l.KVStoreService.OpenKVStore(ctx) // ensure the proof provided is the expected sentinel localhost client proof if !bytes.Equal(proof, SentinelProof) { @@ -127,7 +127,7 @@ func (l LightClientModule) VerifyNonMembership( proof []byte, path exported.Path, ) error { - ibcStore := l.storeService.OpenKVStore(ctx) + ibcStore := l.KVStoreService.OpenKVStore(ctx) // ensure the proof provided is the expected sentinel localhost client proof if !bytes.Equal(proof, SentinelProof) { diff --git a/simapp/app.go b/simapp/app.go index ff443f26b6f..bfbc247cc4a 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -486,7 +486,11 @@ func NewSimApp( app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper) app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, govModuleAddr, + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")), + app.GetSubspace(ibcexported.ModuleName), + app.UpgradeKeeper, + govModuleAddr, ) govRouter := govv1beta1.NewRouter() diff --git a/testing/chain.go b/testing/chain.go index eb1143954a7..357406cb6f5 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -208,8 +208,9 @@ func (chain *TestChain) GetContext() sdk.Context { headerInfo := header.Info{ AppHash: chain.ProposedHeader.AppHash, Hash: cmtHeader.Hash(), - Time: chain.ProposedHeader.Time, ChainID: chain.ProposedHeader.ChainID, + Height: chain.ProposedHeader.Height, + Time: chain.ProposedHeader.Time, } return ctx.WithHeaderInfo(headerInfo) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index fb1c447346f..62e9095d4cf 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -456,7 +456,11 @@ func NewSimApp( app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper) app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, govModuleAddr, + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")), + app.GetSubspace(ibcexported.ModuleName), + app.UpgradeKeeper, + govModuleAddr, ) govRouter := govv1beta1.NewRouter() From bdcb8fdb99963fbad05d1da9fe0f5ccc4fbfca3e Mon Sep 17 00:00:00 2001 From: meoaka3 Date: Fri, 20 Dec 2024 16:19:50 +0700 Subject: [PATCH 09/41] fix TestValidateHostGenesisState" (#7756) Co-authored-by: Damian Nolan --- .../genesis/types/genesis_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index 6fddd5c8a1b..c411257e06f 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -217,12 +217,12 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", func() {}, - true, + nil, }, { "failed to validate active channel - invalid port identifier", @@ -236,7 +236,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.HostPortID, hosttypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate active channel - invalid channel identifier", @@ -250,7 +250,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { genesisState = genesistypes.NewHostGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, icatypes.HostPortID, hosttypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid port identifier", @@ -271,7 +271,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.HostPortID, hosttypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid owner address", @@ -292,7 +292,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, icatypes.HostPortID, hosttypes.DefaultParams()) }, - false, + icatypes.ErrInvalidAccountAddress, }, { "failed to validate controller ports - invalid port identifier", @@ -313,7 +313,7 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { genesisState = genesistypes.NewHostGenesisState(activeChannels, registeredAccounts, "invalid|port", hosttypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, } @@ -327,10 +327,11 @@ func (suite *GenesisTypesTestSuite) TestValidateHostGenesisState() { err := genesisState.Validate() - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) + suite.Require().ErrorIs(err, tc.expErr) } }) } From 23a4a96128789df2ff7cbc760b44088bcd902eef Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 20 Dec 2024 10:38:24 +0100 Subject: [PATCH 10/41] chore: bump wasmvm (#7735) Co-authored-by: DimitrisJim Co-authored-by: Damian Nolan --- modules/light-clients/08-wasm/go.mod | 2 +- modules/light-clients/08-wasm/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index c86523dbcc4..822eef86d1a 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -34,7 +34,7 @@ require ( cosmossdk.io/x/staking v0.0.0-20241218110910-47409028a73d cosmossdk.io/x/tx v1.0.0-alpha.3 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmvm/v2 v2.1.2 + github.com/CosmWasm/wasmvm/v2 v2.1.4 github.com/cometbft/cometbft v1.0.0 github.com/cometbft/cometbft/api v1.0.0 github.com/cosmos/cosmos-db v1.1.1 diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index d74a0aba443..09d1033b1dc 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -271,8 +271,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/wasmvm/v2 v2.1.2 h1:GkJ5bAsRlLHfIQVg/FY1VHwLyBwlCjAhDea0B8L+e20= -github.com/CosmWasm/wasmvm/v2 v2.1.2/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= +github.com/CosmWasm/wasmvm/v2 v2.1.4 h1:7EUVQjBxXHkVjL2AqqXD7hMEe0dmoNn2li9E4PWRAnA= +github.com/CosmWasm/wasmvm/v2 v2.1.4/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= From 0bea84d4e3ecbb45c25f6cba935696e68c1a02e3 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 20 Dec 2024 11:11:10 +0100 Subject: [PATCH 11/41] chore: use header service in localhost client (#7757) --- modules/light-clients/09-localhost/light_client_module.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/light-clients/09-localhost/light_client_module.go b/modules/light-clients/09-localhost/light_client_module.go index cadfa805896..d4d941bfcd0 100644 --- a/modules/light-clients/09-localhost/light_client_module.go +++ b/modules/light-clients/09-localhost/light_client_module.go @@ -8,7 +8,6 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" @@ -167,9 +166,8 @@ func (LightClientModule) LatestHeight(ctx context.Context, _ string) exported.He // TimestampAtHeight returns the current block time retrieved from the application context. The localhost client does not store consensus states and thus // cannot provide a timestamp for the provided height. -func (LightClientModule) TimestampAtHeight(ctx context.Context, _ string, _ exported.Height) (uint64, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917 - return uint64(sdkCtx.BlockTime().UnixNano()), nil +func (l LightClientModule) TimestampAtHeight(ctx context.Context, _ string, _ exported.Height) (uint64, error) { + return uint64(l.HeaderService.HeaderInfo(ctx).Time.UnixNano()), nil } // RecoverClient returns an error. The localhost cannot be modified by proposals. From 78f5392831a7a7d78b301e8117a2069ca5ef69bb Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 20 Dec 2024 11:21:57 +0100 Subject: [PATCH 12/41] chore: fix mergify task for 08-wasm (#7759) --- .github/mergify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index 5255132e514..0aa2342f75b 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -69,7 +69,7 @@ pull_request_rules: actions: backport: branches: - - 08-wasm/release/v0.5.x+ibc-go-v8.4.x-wasmvm-v2.0.x + - 08-wasm/release/v0.5.x+ibc-go-v8.4.x-wasmvm-v2.1.x - name: backport patches to v0.5.x wasm ibc-go v9.0.x & wasmvm 2.1.x branch conditions: - base=main From bb670d245bd0a9a2fc31ce6ee3210d9fb8aa7f10 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Fri, 20 Dec 2024 12:26:01 +0200 Subject: [PATCH 13/41] Axe myself from CODEOWNERS (#7750) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Αντίo και ευχαριστώ για τις καλές στιγμές και τα σκατονομίσματα. --- .github/CODEOWNERS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index aadab8b6813..f7f3404256b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,8 +1,8 @@ # CODEOWNERS: https://help.github.com/articles/about-codeowners/ -* @AdityaSripal @damiannolan @DimitrisJim @gjermundgaraba +* @AdityaSripal @damiannolan @gjermundgaraba -# Our appreciation and gratitude to past code owners: @fedekunze @seantking @tmsdkeys @charleenfei @crodriguezvega @colin-axner @chatton @bznein +# Our appreciation and gratitude to past code owners: @fedekunze @seantking @tmsdkeys @charleenfei @crodriguezvega @colin-axner @chatton @bznein @DimitrisJim # Order is important; the last matching pattern takes the most # precedence. When someone opens a pull request that only @@ -25,12 +25,12 @@ # CODEOWNERS for 08-wasm light client module -/modules/light-clients/08-wasm/ @AdityaSripal @damiannolan @DimitrisJim @srdtrk +/modules/light-clients/08-wasm/ @AdityaSripal @damiannolan @srdtrk # CODEOWNERS for ICS 20 -/modules/apps/transfer/ @AdityaSripal @damiannolan @DimitrisJim -/proto/ibc/applications/transfer/ @AdityaSripal @damiannolan @DimitrisJim +/modules/apps/transfer/ @AdityaSripal @damiannolan +/proto/ibc/applications/transfer/ @AdityaSripal @damiannolan # CODEOWNERS for interchain-accounts module @@ -48,5 +48,5 @@ # CODEOWNERS for docs -/docs/ @AdityaSripal @damiannolan @DimitrisJim @srdtrk +/docs/ @AdityaSripal @damiannolan @srdtrk From ec65d27bf68cf804ae9e20893e0922bc20690169 Mon Sep 17 00:00:00 2001 From: meoaka3 Date: Fri, 20 Dec 2024 19:57:31 +0700 Subject: [PATCH 14/41] fix TestGenesisAccountValidate" (#7763) Co-authored-by: Damian Nolan --- .../27-interchain-accounts/types/account_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/account_test.go b/modules/apps/27-interchain-accounts/types/account_test.go index 996d5b85e21..da81f1e1f85 100644 --- a/modules/apps/27-interchain-accounts/types/account_test.go +++ b/modules/apps/27-interchain-accounts/types/account_test.go @@ -120,19 +120,19 @@ func (suite *TypesTestSuite) TestGenesisAccountValidate() { ownerAddr := sdk.AccAddress(pubkey.Address()) testCases := []struct { - name string - acc authtypes.GenesisAccount - expPass bool + name string + acc authtypes.GenesisAccount + expErr error }{ { "success", types.NewInterchainAccount(baseAcc, ownerAddr.String()), - true, + nil, }, { "interchain account with empty AccountOwner field", types.NewInterchainAccount(baseAcc, ""), - false, + types.ErrInvalidAccountAddress, }, } @@ -141,10 +141,11 @@ func (suite *TypesTestSuite) TestGenesisAccountValidate() { err := tc.acc.Validate() - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } } } From 1b51f87d8a900b9bbbadab3d044812ad9d149089 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:33:54 +0100 Subject: [PATCH 15/41] chore(deps): bump bufbuild/buf-setup-action from 1.47.2 to 1.48.0 (#7765) Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.47.2 to 1.48.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.47.2...v1.48.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/proto-registry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index 621f5d11088..4f544088352 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.47.2 + - uses: bufbuild/buf-setup-action@v1.48.0 - uses: bufbuild/buf-push-action@v1 with: input: "proto" From a2037c7ec3bd400c4aef358c176ca59e8660940a Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 20 Dec 2024 18:08:50 +0100 Subject: [PATCH 16/41] chore: fix spell-checker (#7774) * chore: fix spell-checker * install codespell with pip --- .github/workflows/spell-checker.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/spell-checker.yml b/.github/workflows/spell-checker.yml index 85f5845ea86..e2399eaa619 100644 --- a/.github/workflows/spell-checker.yml +++ b/.github/workflows/spell-checker.yml @@ -1,6 +1,7 @@ name: Spell Check on: + workflow_dispatch: pull_request: schedule: - cron: "0 12 * * *" @@ -15,11 +16,14 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install codespell + run: pip install codespell - name: Run codespell continue-on-error: true - run: | - sudo apt-get install codespell -y - codespell -w --skip="*.pb.go,*.pb.gw.go,*.json,*.git,*.js,*.h,*.bin,go.sum,go.mod,.github" --ignore-words=.github/.codespellignore + run: codespell -w --skip="*.pb.go,*.pb.gw.go,*.json,*.git,*.js,*.h,*.bin,go.sum,go.mod,.github,*.pdf,*.tla" --ignore-words=.github/.codespellignore - uses: peter-evans/create-pull-request@v7 if: github.event_name != 'pull_request' with: From 3ffb0e7a15f87a16d1d8d83849be87d52bc29cde Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:10:13 +0100 Subject: [PATCH 17/41] chore: spelling errors fixes (#7776) Co-authored-by: gjermundgaraba <1344105+gjermundgaraba@users.noreply.github.com> --- docs/versioned_docs/version-v4.6.x/04-migrations/05-v3-to-v4.md | 2 +- docs/versioned_docs/version-v5.4.x/04-migrations/05-v3-to-v4.md | 2 +- docs/versioned_docs/version-v6.3.x/04-migrations/05-v3-to-v4.md | 2 +- docs/versioned_docs/version-v7.8.x/05-migrations/05-v3-to-v4.md | 2 +- docs/versioned_docs/version-v8.5.x/00-intro.md | 2 +- .../versioned_docs/version-v8.5.x/01-ibc/06-channel-upgrades.md | 2 +- docs/versioned_docs/version-v8.5.x/05-migrations/05-v3-to-v4.md | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/versioned_docs/version-v4.6.x/04-migrations/05-v3-to-v4.md b/docs/versioned_docs/version-v4.6.x/04-migrations/05-v3-to-v4.md index d916ec51252..958c6bd1328 100644 --- a/docs/versioned_docs/version-v4.6.x/04-migrations/05-v3-to-v4.md +++ b/docs/versioned_docs/version-v4.6.x/04-migrations/05-v3-to-v4.md @@ -41,7 +41,7 @@ where `icaAuthIBCModule` is the Interchain Accounts authentication IBC Module. The Fee Middleware module, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. -Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to congfigure the module correctly in order to incentivize IBC packets. +Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to configure the module correctly in order to incentivize IBC packets. Take a look at the following diff for an [example setup](https://github.com/cosmos/ibc-go/pull/1432/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08aL366) of how to incentivize ics27 channels. diff --git a/docs/versioned_docs/version-v5.4.x/04-migrations/05-v3-to-v4.md b/docs/versioned_docs/version-v5.4.x/04-migrations/05-v3-to-v4.md index d916ec51252..958c6bd1328 100644 --- a/docs/versioned_docs/version-v5.4.x/04-migrations/05-v3-to-v4.md +++ b/docs/versioned_docs/version-v5.4.x/04-migrations/05-v3-to-v4.md @@ -41,7 +41,7 @@ where `icaAuthIBCModule` is the Interchain Accounts authentication IBC Module. The Fee Middleware module, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. -Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to congfigure the module correctly in order to incentivize IBC packets. +Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to configure the module correctly in order to incentivize IBC packets. Take a look at the following diff for an [example setup](https://github.com/cosmos/ibc-go/pull/1432/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08aL366) of how to incentivize ics27 channels. diff --git a/docs/versioned_docs/version-v6.3.x/04-migrations/05-v3-to-v4.md b/docs/versioned_docs/version-v6.3.x/04-migrations/05-v3-to-v4.md index 859e135b1d6..ce5db2233d9 100644 --- a/docs/versioned_docs/version-v6.3.x/04-migrations/05-v3-to-v4.md +++ b/docs/versioned_docs/version-v6.3.x/04-migrations/05-v3-to-v4.md @@ -41,7 +41,7 @@ where `icaAuthIBCModule` is the Interchain Accounts authentication IBC Module. The Fee Middleware module, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. -Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to congfigure the module correctly in order to incentivize IBC packets. +Please read the Fee Middleware [integration documentation](../03-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to configure the module correctly in order to incentivize IBC packets. Take a look at the following diff for an [example setup](https://github.com/cosmos/ibc-go/pull/1432/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08aL366) of how to incentivize ics27 channels. diff --git a/docs/versioned_docs/version-v7.8.x/05-migrations/05-v3-to-v4.md b/docs/versioned_docs/version-v7.8.x/05-migrations/05-v3-to-v4.md index 0c6f5fa35e5..60cc1c924eb 100644 --- a/docs/versioned_docs/version-v7.8.x/05-migrations/05-v3-to-v4.md +++ b/docs/versioned_docs/version-v7.8.x/05-migrations/05-v3-to-v4.md @@ -41,7 +41,7 @@ where `icaAuthIBCModule` is the Interchain Accounts authentication IBC Module. The Fee Middleware module, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. -Please read the Fee Middleware [integration documentation](../04-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to congfigure the module correctly in order to incentivize IBC packets. +Please read the Fee Middleware [integration documentation](../04-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to configure the module correctly in order to incentivize IBC packets. Take a look at the following diff for an [example setup](https://github.com/cosmos/ibc-go/pull/1432/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08aL366) of how to incentivize ics27 channels. diff --git a/docs/versioned_docs/version-v8.5.x/00-intro.md b/docs/versioned_docs/version-v8.5.x/00-intro.md index 7f4a09fb1af..a21bdf40058 100644 --- a/docs/versioned_docs/version-v8.5.x/00-intro.md +++ b/docs/versioned_docs/version-v8.5.x/00-intro.md @@ -27,7 +27,7 @@ IBC provides a reliable, permissionless, and generic base layer (allowing for th - **IBC/TAO** comprises the Transport, Authentication, and Ordering of packets, i.e. the infrastructure layer. - **IBC/APP** consists of the application handlers for the data packets being passed over the transport layer. These include but are not limited to fungible token transfers (ICS-20), NFT transfers (ICS-721), and interchain accounts (ICS-27). -- **Application module:** groups any application, middleware or smart contract that may wrap downsteam application handlers to provide enhanced functionality. +- **Application module:** groups any application, middleware or smart contract that may wrap downstream application handlers to provide enhanced functionality. Note three crucial elements in the diagram: diff --git a/docs/versioned_docs/version-v8.5.x/01-ibc/06-channel-upgrades.md b/docs/versioned_docs/version-v8.5.x/01-ibc/06-channel-upgrades.md index 841d11f42fd..e8e7df83efd 100644 --- a/docs/versioned_docs/version-v8.5.x/01-ibc/06-channel-upgrades.md +++ b/docs/versioned_docs/version-v8.5.x/01-ibc/06-channel-upgrades.md @@ -132,7 +132,7 @@ type Channel struct { This will also set the upgrade timeout for the counterparty (i.e. the timeout before which the counterparty chain must move from `FLUSHING` to `FLUSHCOMPLETE`; if it doesn't then the chain will cancel the upgrade and write an error receipt). The timeout is a relative time duration in nanoseconds that can be changed with `MsgUpdateParams` and by default is 10 minutes. -The state will change to `FLUSHCOMPLETE` once there are no in-flight packets left and the channel end is ready to move to `OPEN`. This flush state will also have an impact on how a channel ugrade can be cancelled, as detailed below. +The state will change to `FLUSHCOMPLETE` once there are no in-flight packets left and the channel end is ready to move to `OPEN`. This flush state will also have an impact on how a channel upgrade can be cancelled, as detailed below. All other parameters will remain the same during the upgrade handshake until the upgrade handshake completes. When the channel is reset to `OPEN` on a successful upgrade handshake, the relevant fields on the channel end will be switched over to the `UpgradeFields` specified in the upgrade. diff --git a/docs/versioned_docs/version-v8.5.x/05-migrations/05-v3-to-v4.md b/docs/versioned_docs/version-v8.5.x/05-migrations/05-v3-to-v4.md index 6707286eadc..091e11375ef 100644 --- a/docs/versioned_docs/version-v8.5.x/05-migrations/05-v3-to-v4.md +++ b/docs/versioned_docs/version-v8.5.x/05-migrations/05-v3-to-v4.md @@ -41,7 +41,7 @@ where `icaAuthIBCModule` is the Interchain Accounts authentication IBC Module. The Fee Middleware module, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. -Please read the Fee Middleware [integration documentation](../04-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to congfigure the module correctly in order to incentivize IBC packets. +Please read the Fee Middleware [integration documentation](../04-middleware/01-ics29-fee/02-integration.md) for an in depth guide on how to configure the module correctly in order to incentivize IBC packets. Take a look at the following diff for an [example setup](https://github.com/cosmos/ibc-go/pull/1432/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08aL366) of how to incentivize ics27 channels. From a8369a944d2ac197fcc1ee49e9db4760255e28ac Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Fri, 20 Dec 2024 18:10:48 +0100 Subject: [PATCH 18/41] chore: remove unecessary/unused github actions (#7772) --- .github/workflows/discord-notify.yml | 16 ------------- .github/workflows/release.yml | 21 ---------------- .github/workflows/slack-notify.yaml | 17 ------------- .goreleaser.yml | 36 ---------------------------- 4 files changed, 90 deletions(-) delete mode 100644 .github/workflows/discord-notify.yml delete mode 100644 .github/workflows/slack-notify.yaml delete mode 100644 .goreleaser.yml diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml deleted file mode 100644 index efc8d40559e..00000000000 --- a/.github/workflows/discord-notify.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Notify Discord on Release - -on: - release: - types: [published] - -jobs: - notify: - runs-on: ubuntu-latest - steps: - - name: Send Notification to Discord - uses: Ilshidur/action-discord@2.4.0 - with: - args: "A new release of ibc-go has been tagged! View it here: ${{ github.event.release.html_url }}" - webhook: ${{ secrets.DISCORD_WEBHOOK }} - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 813b13fcc4a..524f98d6657 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,27 +11,6 @@ env: IMAGE_NAME: ibc-go-simd jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version: '1.23' - - - name: Release - uses: goreleaser/goreleaser-action@v6 - if: startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish-docker-image: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/slack-notify.yaml b/.github/workflows/slack-notify.yaml deleted file mode 100644 index e57ee00e701..00000000000 --- a/.github/workflows/slack-notify.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# This re-usable workflow file will trigger a Slack notification on the channel configure via the Webhook URL. -# It currently comments a number of fields, but you can add or remove them as you see fit. -# -# To configure a Slack Webhook URL, follow the instructions here: https://api.slack.com/messaging/webhooks -on: - workflow_call: - -jobs: - slack-notify: - runs-on: ubuntu-latest - steps: - - uses: 8398a7/action-slack@v3 - with: - status: 'failure' - fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 63ecd8822e7..00000000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,36 +0,0 @@ -before: - hooks: - - go mod tidy - -builds: - - main: ./testing/simapp/simd/main.go - binary: simd - flags: - - -tags=netgo ledger - - -mod=readonly - ldflags: - - -s -w -X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - # for goarch use defaults: 386, amd64 and arm64. - -checksum: - name_template: SHA256SUMS-{{.Version}}.txt - algorithm: sha256 - -release: - mode: keep-existing - prerelease: auto - -archives: - - name_template: "{{ .ProjectName }}_simd_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" - files: - - LICENSE - - README.md - - RELEASES.md - - SECURITY.md - - CHANGELOG.md From ed43b4822f59e71132dacc3c5a6ec0deb8b6ca52 Mon Sep 17 00:00:00 2001 From: meoikia Date: Sat, 21 Dec 2024 01:01:09 +0700 Subject: [PATCH 19/41] no need to declare new variables (#7751) Co-authored-by: Damian Nolan Co-authored-by: Gjermund Garaba --- .../controller/keeper/handshake_test.go | 10 +--- .../host/keeper/handshake_test.go | 3 +- .../host/keeper/relay_test.go | 6 +- .../host/types/msgs_test.go | 3 +- modules/apps/29-fee/ibc_middleware_test.go | 9 +-- modules/apps/29-fee/transfer_test.go | 3 +- modules/apps/callbacks/ibc_middleware_test.go | 3 +- .../apps/callbacks/types/callbacks_test.go | 3 +- modules/apps/transfer/ibc_module_test.go | 24 +++----- .../apps/transfer/keeper/msg_server_test.go | 3 +- modules/apps/transfer/keeper/relay_test.go | 18 ++---- .../apps/transfer/types/forwarding_test.go | 9 +-- modules/apps/transfer/types/msgs_test.go | 6 +- modules/apps/transfer/types/packet_test.go | 12 ++-- modules/apps/transfer/types/token_test.go | 6 +- .../core/02-client/keeper/grpc_query_test.go | 3 +- modules/core/02-client/keeper/keeper_test.go | 3 +- modules/core/02-client/types/msgs_test.go | 12 ++-- modules/core/04-channel/keeper/ante_test.go | 3 +- modules/core/04-channel/keeper/packet_test.go | 3 +- .../core/04-channel/keeper/upgrade_test.go | 18 ++---- modules/core/04-channel/types/msgs_test.go | 57 +++++++------------ modules/core/keeper/msg_server_test.go | 6 +- .../light_client_module_test.go | 27 +++------ .../07-tendermint/client_state_test.go | 3 +- .../07-tendermint/light_client_module_test.go | 21 +++---- .../07-tendermint/upgrade_test.go | 3 +- .../08-wasm/internal/types/store_test.go | 3 +- .../08-wasm/keeper/contract_keeper_test.go | 12 ++-- .../08-wasm/keeper/querier_test.go | 6 +- .../08-wasm/light_client_module_test.go | 21 +++---- .../light-clients/08-wasm/types/msgs_test.go | 3 +- 32 files changed, 107 insertions(+), 215 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go index e841feba14e..d781b0c2938 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake_test.go @@ -298,8 +298,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel.Counterparty, channel.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(expectedVersion, version) } else { @@ -686,9 +685,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeInit() { version, ) - expPass := tc.expError == nil - - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(upgradeVersion, version) } else { @@ -857,8 +854,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeAck() { counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, counterpartyVersion) } else { diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 7fea0c075f3..c3b2f90ef17 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -597,8 +597,7 @@ func (suite *KeeperTestSuite) TestOnChanUpgradeTry() { counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointB.GetChannel().Version, version) } else { diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 15f89ca65ba..e2790b1dfe4 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -545,8 +545,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { txResponse, err := suite.chainB.GetSimApp().ICAHostKeeper.OnRecvPacket(suite.chainB.GetContext(), packet) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(txResponse) } else { @@ -874,8 +873,7 @@ func (suite *KeeperTestSuite) TestJSONOnRecvPacket() { txResponse, err := suite.chainB.GetSimApp().ICAHostKeeper.OnRecvPacket(suite.chainB.GetContext(), packet) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(txResponse) } else { diff --git a/modules/apps/27-interchain-accounts/host/types/msgs_test.go b/modules/apps/27-interchain-accounts/host/types/msgs_test.go index 3a495b0d9c6..b353a143197 100644 --- a/modules/apps/27-interchain-accounts/host/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/host/types/msgs_test.go @@ -111,8 +111,7 @@ func TestMsgModuleQuerySafeValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) } else { require.Error(t, err) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 7a388ac1748..45a52283a02 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -1118,8 +1118,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeInit() { err := path.EndpointA.ChanUpgradeInit() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1231,8 +1230,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeTry() { err = path.EndpointB.ChanUpgradeTry() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1338,8 +1336,7 @@ func (suite *FeeTestSuite) TestOnChanUpgradeAck() { err = cbs.OnChanUpgradeAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyUpgrade.Fields.Version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go index aef236eb86e..a743d2f718f 100644 --- a/modules/apps/29-fee/transfer_test.go +++ b/modules/apps/29-fee/transfer_test.go @@ -139,8 +139,7 @@ func (suite *FeeTestSuite) TestTransferFeeUpgrade() { err = path.EndpointA.ChanUpgradeOpen() suite.Require().NoError(err) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { channelA := path.EndpointA.GetChannel() suite.Require().Equal(upgradeVersion, channelA.Version) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index a19d85900c2..00cd58bc20a 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -71,8 +71,7 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { s.Require().NotPanics(tc.instantiateFn, "unexpected panic: NewIBCMiddleware") } else { s.Require().PanicsWithError(tc.expError.Error(), tc.instantiateFn, "expected panic with error: ", tc.expError.Error()) diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index 735e7316ed3..82e73172fa0 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -549,8 +549,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { callbackData, err := types.GetCallbackData(packetData, version, transfertypes.PortID, remainingGas, uint64(1_000_000), callbackKey) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { s.Require().NoError(err, tc.name) s.Require().Equal(tc.expCallbackData, callbackData, tc.name) diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 47cbc1ac554..c11a88bf04d 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -101,8 +101,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterparty, channel.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(tc.expVersion, version) } else { @@ -186,8 +185,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { version, err := cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel.Counterparty, counterpartyVersion, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(tc.expVersion, version) } else { @@ -236,8 +234,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { err := cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointA.Counterparty.ChannelID, counterpartyVersion) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -472,8 +469,7 @@ func (suite *TransferTestSuite) TestOnTimeoutPacket() { err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), path.EndpointA.GetChannel().Version, packet, suite.chainA.SenderAccount.GetAddress()) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) escrowAddress := types.GetEscrowAddress(packet.GetSourcePort(), packet.GetSourceChannel()) @@ -545,8 +541,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeInit() { err := path.EndpointA.ChanUpgradeInit() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) upgrade := path.EndpointA.GetChannelUpgrade() suite.Require().Equal(upgradePath.EndpointA.ConnectionID, upgrade.Fields.ConnectionHops[0]) @@ -623,8 +618,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeTry() { counterpartyUpgrade.Fields.Ordering, counterpartyUpgrade.Fields.ConnectionHops, counterpartyUpgrade.Fields.Version, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(types.V2, version) } else { @@ -688,8 +682,7 @@ func (suite *TransferTestSuite) TestOnChanUpgradeAck() { err = cbs.OnChanUpgradeAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.Version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -847,8 +840,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { packetData, version, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) v2PacketData, ok := packetData.(types.FungibleTokenPacketDataV2) diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 13b0d9369e4..a6530d8c6d6 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -183,8 +183,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { ), }.ToABCIEvents() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().NotEqual(res.Sequence, uint64(0)) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index ff3a0d03eab..b544ee0cf5d 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -279,8 +279,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(suite.chainA.GetContext(), msg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { @@ -466,8 +465,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsNotSource() { err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, packetData) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) // Check denom metadata for of tokens received on chain B. @@ -593,8 +591,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { packet := channeltypes.NewPacket(packetData.GetBytes(), uint64(1), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0) err = suite.chainA.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainA.GetContext(), packet, packetData) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) _, found := suite.chainA.GetSimApp().BankKeeper.GetDenomMetaData(suite.chainA.GetContext(), sdk.DefaultBondDenom) @@ -809,8 +806,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { totalEscrow := suite.chainA.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainA.GetContext(), denom.IBCDenom()) suite.Require().Equal(expEscrowAmount, totalEscrow.Amount) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) postAcknowledgementBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), denom.IBCDenom()) deltaAmount := postAcknowledgementBalance.Amount.Sub(preAcknowledgementBalance.Amount) @@ -1047,8 +1043,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { totalEscrow := suite.chainA.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainA.GetContext(), denom.IBCDenom()) suite.Require().Equal(expEscrowAmount, totalEscrow.Amount) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) amountParsed, ok := sdkmath.NewIntFromString(amount) suite.Require().True(ok) @@ -1230,8 +1225,7 @@ func (suite *KeeperTestSuite) TestPacketForwardsCompatibility() { // receive packet on chainA err = path.RelayPacket(packet) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expError.Error()) diff --git a/modules/apps/transfer/types/forwarding_test.go b/modules/apps/transfer/types/forwarding_test.go index e7dce4814e8..e1b0a102dbf 100644 --- a/modules/apps/transfer/types/forwarding_test.go +++ b/modules/apps/transfer/types/forwarding_test.go @@ -98,8 +98,7 @@ func TestForwarding_Validate(t *testing.T) { err := tc.forwarding.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -209,8 +208,7 @@ func TestForwardingPacketData_Validate(t *testing.T) { err := tc.forwarding.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -267,8 +265,7 @@ func TestValidateHop(t *testing.T) { err := tc.hop.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 7c2f070b353..2a1a943a000 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -97,8 +97,7 @@ func TestMsgTransferValidation(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) @@ -134,8 +133,7 @@ func TestMsgUpdateParamsValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expError) diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 5da67149fca..44636e4ddd8 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -484,8 +484,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { t.Run(tc.name, func(t *testing.T) { err := tc.packetData.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expErr.Error(), tc.name) @@ -767,8 +766,7 @@ func TestUnmarshalPacketData(t *testing.T) { packetData, err := types.UnmarshalPacketData(packetDataBz, version) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.IsType(t, types.FungibleTokenPacketDataV2{}, packetData) } else { require.ErrorIs(t, err, tc.expError) @@ -821,8 +819,7 @@ func TestV2ForwardsCompatibilityFails(t *testing.T) { packetData, err := types.UnmarshalPacketData(packetDataBz, types.V2) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err) require.NotEqual(t, types.FungibleTokenPacketDataV2{}, packetData) } else { @@ -938,8 +935,7 @@ func TestPacketV1ToPacketV2(t *testing.T) { for _, tc := range testCases { actualV2Data, err := types.PacketDataV1ToV2(tc.v1Data) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, "test case: %s", tc.name) require.Equal(t, tc.v2Data, actualV2Data, "test case: %s", tc.name) } else { diff --git a/modules/apps/transfer/types/token_test.go b/modules/apps/transfer/types/token_test.go index f349765822b..929ba3b5f78 100644 --- a/modules/apps/transfer/types/token_test.go +++ b/modules/apps/transfer/types/token_test.go @@ -144,8 +144,7 @@ func TestValidate(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { err := tc.token.Validate() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expError.Error(), tc.name) @@ -193,8 +192,7 @@ func TestToCoin(t *testing.T) { require.Equal(t, tc.expCoin, coin, tc.name) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { require.ErrorContains(t, err, tc.expError.Error(), tc.name) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index e84323d64d9..1abaa4a1d15 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -948,8 +948,7 @@ func (suite *KeeperTestSuite) TestQueryVerifyMembershipProof() { queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) res, err := queryServer.VerifyMembership(ctx, req) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().True(res.Success, "failed to verify membership proof") diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 9b230fec827..caba6fc0a8e 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -452,8 +452,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { actualTimestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientTimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(uint64(suite.chainB.LatestCommittedHeader.GetTime().UnixNano()), actualTimestamp) } else { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index 6942379d57a..fa1d7fa51b1 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -684,8 +684,7 @@ func (suite *TypesTestSuite) TestMsgRecoverClientValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err, "valid case %s failed", tc.name) } else { suite.Require().Error(err, "invalid case %s passed", tc.name) @@ -801,8 +800,7 @@ func TestMsgIBCSoftwareUpgrade_GetSigners(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, ibc.AppModule{}) signers, _, err := encodingCfg.Codec.GetMsgSigners(msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) require.Equal(t, tc.address.Bytes(), signers[0]) } else { @@ -872,9 +870,8 @@ func (suite *TypesTestSuite) TestMsgIBCSoftwareUpgrade_ValidateBasic() { } err = msg.ValidateBasic() - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } if tc.expError != nil { @@ -976,8 +973,7 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) { encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, ibc.AppModule{}) signers, _, err := encodingCfg.Codec.GetMsgSigners(&msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) require.Equal(t, tc.address.Bytes(), signers[0]) } else { diff --git a/modules/core/04-channel/keeper/ante_test.go b/modules/core/04-channel/keeper/ante_test.go index 4332788baaf..4de476a81f5 100644 --- a/modules/core/04-channel/keeper/ante_test.go +++ b/modules/core/04-channel/keeper/ante_test.go @@ -53,8 +53,7 @@ func (suite *KeeperTestSuite) TestRecvPacketReCheckTx() { err = suite.chainB.App.GetIBCKeeper().ChannelKeeper.RecvPacketReCheckTx(suite.chainB.GetContext(), packet) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 38fb54b2ad3..973b5d605e1 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -596,8 +596,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelVersion, err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.RecvPacket(suite.chainB.GetContext(), packet, proof, proofHeight) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, channelVersion, "channel version is incorrect") diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 8565f12a195..26ee0e22b6d 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -295,7 +295,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - expPass := tc.expError == nil path = ibctesting.NewPath(suite.chainA, suite.chainB) path.Setup() @@ -330,7 +329,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() { proofHeight, ) - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotEmpty(upgrade) suite.Require().Equal(proposedUpgrade.Fields, upgrade.Fields) @@ -782,8 +781,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { channelProof, upgradeProof, proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) channel := path.EndpointA.GetChannel() @@ -1132,8 +1130,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeConfirm() { channelProof, upgradeProof, proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.assertUpgradeError(err, tc.expError) @@ -1843,8 +1840,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeCancel() { err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeCancel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, errorReceipt, errorReceiptProof, proofHeight) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -2174,7 +2170,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - expPass := tc.expError == nil path = ibctesting.NewPath(suite.chainA, suite.chainB) path.Setup() @@ -2200,7 +2195,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeTimeout() { proofHeight, ) - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.assertUpgradeError(err, tc.expError) @@ -2686,8 +2681,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeCrossingHelloWithHistoricalProofs() proofHeight, ) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotEmpty(upgrade) } else { diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index b789fe5f550..ba1f7e6f289 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -249,8 +249,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -421,8 +420,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTryValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -532,8 +530,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenAckValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -627,8 +624,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenConfirmValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -717,8 +713,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseInitValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -817,8 +812,7 @@ func (suite *TypesTestSuite) TestMsgChannelCloseConfirmValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -874,8 +868,7 @@ func (suite *TypesTestSuite) TestMsgRecvPacketValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.NoError(err) } else { suite.Error(err) @@ -936,8 +929,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1008,8 +1000,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1070,8 +1061,7 @@ func (suite *TypesTestSuite) TestMsgAcknowledgementValidateBasic() { suite.Run(tc.name, func() { err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1154,8 +1144,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeInitValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1278,8 +1267,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTryValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1385,8 +1373,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeAckValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1506,8 +1493,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeConfirmValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1613,8 +1599,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeOpenValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1693,8 +1678,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1778,8 +1762,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeCancelValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) @@ -1852,8 +1835,7 @@ func (suite *TypesTestSuite) TestMsgPruneAcknowledgementsValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -1907,8 +1889,7 @@ func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() { tc.malleate() err := msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index d9cbff138a4..fef6d2acfb5 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -277,8 +277,7 @@ func (suite *KeeperTestSuite) TestRecoverClient() { _, err = suite.chainA.App.GetIBCKeeper().RecoverClient(suite.chainA.GetContext(), msg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // Assert that client status is now Active @@ -2678,8 +2677,7 @@ func (suite *KeeperTestSuite) TestUpdateChannelParams() { suite.Run(tc.name, func() { suite.SetupTest() resp, err := suite.chainA.App.GetIBCKeeper().UpdateChannelParams(suite.chainA.GetContext(), tc.msg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(resp) p := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetParams(suite.chainA.GetContext()) diff --git a/modules/light-clients/06-solomachine/light_client_module_test.go b/modules/light-clients/06-solomachine/light_client_module_test.go index 08c6d1f2945..2141687a29c 100644 --- a/modules/light-clients/06-solomachine/light_client_module_test.go +++ b/modules/light-clients/06-solomachine/light_client_module_test.go @@ -203,8 +203,7 @@ func (suite *SoloMachineTestSuite) TestInitialize() { err = lightClientModule.Initialize(suite.chainA.GetContext(), clientID, clientStateBz, consStateBz) store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().True(store.Has(host.ClientStateKey())) } else { @@ -679,8 +678,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { 0, 0, proof, path, signBytes.Data, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { // Grab fresh client state after updates. cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), clientID) suite.Require().True(found) @@ -904,8 +902,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() { 0, 0, proof, path, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { // Grab fresh client state after updates. cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), clientID) suite.Require().True(found) @@ -1001,8 +998,7 @@ func (suite *SoloMachineTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(ctx, subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // assert that status of subject client is now Active @@ -1084,8 +1080,7 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { consensusHeights = lightClientModule.UpdateState(suite.chainA.GetContext(), clientID, clientMsg) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { updateStateFunc() clientStateBz := store.Get(host.ClientStateKey()) @@ -1174,8 +1169,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { foundMisbehaviour = lightClientModule.CheckForMisbehaviour(suite.chainA.GetContext(), clientID, clientMsg) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { foundMisbehaviourFunc() suite.Require().Equal(tc.foundMisbehaviour, foundMisbehaviour) @@ -1230,8 +1224,7 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { lightClientModule.UpdateStateOnMisbehaviour(suite.chainA.GetContext(), clientID, nil) } - expPass := tc.expPanic == nil - if expPass { + if tc.expPanic == nil { updateOnMisbehaviourFunc() store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) @@ -1406,8 +1399,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -1652,8 +1644,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) diff --git a/modules/light-clients/07-tendermint/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go index 82aecf465da..1b962873a4c 100644 --- a/modules/light-clients/07-tendermint/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -126,8 +126,7 @@ func (suite *TendermintTestSuite) TestValidate() { suite.Run(tc.name, func() { err := tc.clientState.Validate() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) diff --git a/modules/light-clients/07-tendermint/light_client_module_test.go b/modules/light-clients/07-tendermint/light_client_module_test.go index 87119309949..5a44b6d0baa 100644 --- a/modules/light-clients/07-tendermint/light_client_module_test.go +++ b/modules/light-clients/07-tendermint/light_client_module_test.go @@ -103,8 +103,7 @@ func (suite *TendermintTestSuite) TestInitialize() { store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, "valid case returned an error") suite.Require().True(store.Has(host.ClientStateKey())) suite.Require().True(store.Has(host.ConsensusStateKey(suite.chainB.LatestCommittedHeader.GetHeight()))) @@ -162,8 +161,7 @@ func (suite *TendermintTestSuite) TestVerifyClientMessage() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), path.EndpointA.ClientID, header) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -515,8 +513,7 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { suite.chainA.GetContext(), testingpath.EndpointA.ClientID, proofHeight, delayTimePeriod, delayBlockPeriod, proof, path, value, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -741,8 +738,7 @@ func (suite *TendermintTestSuite) TestVerifyNonMembership() { proof, path, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expErr.Error()) @@ -934,8 +930,7 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() { timestamp, err := lightClientModule.TimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) expectedTimestamp := uint64(expectedTimestamp.UnixNano()) @@ -1021,8 +1016,7 @@ func (suite *TendermintTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(ctx, subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // assert that status of subject client is now Active @@ -1184,8 +1178,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgradeAndUpdateState() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) expClientState := path.EndpointA.GetClientState() diff --git a/modules/light-clients/07-tendermint/upgrade_test.go b/modules/light-clients/07-tendermint/upgrade_test.go index ea653cba82e..5fcda9454d3 100644 --- a/modules/light-clients/07-tendermint/upgrade_test.go +++ b/modules/light-clients/07-tendermint/upgrade_test.go @@ -583,8 +583,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name) clientState, ok := suite.chainA.GetClientState(path.EndpointA.ClientID).(*ibctm.ClientState) diff --git a/modules/light-clients/08-wasm/internal/types/store_test.go b/modules/light-clients/08-wasm/internal/types/store_test.go index 7234e70bb07..b063acbe0b2 100644 --- a/modules/light-clients/08-wasm/internal/types/store_test.go +++ b/modules/light-clients/08-wasm/internal/types/store_test.go @@ -417,8 +417,7 @@ func (suite *TypesTestSuite) TestNewClientRecoveryStore() { suite.Run(tc.name, func() { tc.malleate() - expPass := !tc.expPanic - if expPass { + if !tc.expPanic { suite.Require().NotPanics(func() { internaltypes.NewClientRecoveryStore(subjectStore, substituteStore) }) diff --git a/modules/light-clients/08-wasm/keeper/contract_keeper_test.go b/modules/light-clients/08-wasm/keeper/contract_keeper_test.go index 86e213aef79..c22ffd4a378 100644 --- a/modules/light-clients/08-wasm/keeper/contract_keeper_test.go +++ b/modules/light-clients/08-wasm/keeper/contract_keeper_test.go @@ -179,8 +179,7 @@ func (suite *KeeperTestSuite) TestWasmInstantiate() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper err := wasmClientKeeper.WasmInstantiate(suite.chainA.GetContext(), defaultWasmClientID, clientStore, &types.ClientState{Checksum: checksum}, initMsg) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -318,8 +317,7 @@ func (suite *KeeperTestSuite) TestWasmMigrate() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper err = wasmClientKeeper.WasmMigrate(suite.chainA.GetContext(), clientStore, &types.ClientState{}, defaultWasmClientID, []byte("{}")) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expError) @@ -396,8 +394,7 @@ func (suite *KeeperTestSuite) TestWasmQuery() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, wasmClientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { @@ -552,8 +549,7 @@ func (suite *KeeperTestSuite) TestWasmSudo() { wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper res, err := wasmClientKeeper.WasmSudo(suite.chainA.GetContext(), endpoint.ClientID, clientStore, wasmClientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { diff --git a/modules/light-clients/08-wasm/keeper/querier_test.go b/modules/light-clients/08-wasm/keeper/querier_test.go index e9362fb24f4..e1b31efe032 100644 --- a/modules/light-clients/08-wasm/keeper/querier_test.go +++ b/modules/light-clients/08-wasm/keeper/querier_test.go @@ -119,8 +119,7 @@ func (suite *KeeperTestSuite) TestCustomQuery() { res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, clientState, types.QueryMsg{Status: &types.StatusMsg{}}) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().Nil(err) suite.Require().NotNil(res) } else { @@ -330,8 +329,7 @@ func (suite *KeeperTestSuite) TestStargateQuery() { // due to test case: "success: verify membership query" res, err := wasmClientKeeper.WasmQuery(suite.chainA.GetContext(), endpoint.ClientID, clientStore, clientState, payload) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) suite.Require().NotNil(res) } else { diff --git a/modules/light-clients/08-wasm/light_client_module_test.go b/modules/light-clients/08-wasm/light_client_module_test.go index 53979978335..43ae4027ae4 100644 --- a/modules/light-clients/08-wasm/light_client_module_test.go +++ b/modules/light-clients/08-wasm/light_client_module_test.go @@ -223,8 +223,7 @@ func (suite *WasmTestSuite) TestTimestampAtHeight() { timestamp, err := lightClientModule.TimestampAtHeight(suite.chainA.GetContext(), clientID, height) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().Equal(expectedTimestamp, timestamp) } else { @@ -351,8 +350,7 @@ func (suite *WasmTestSuite) TestInitialize() { err = lightClientModule.Initialize(suite.chainA.GetContext(), clientID, clientStateBz, consensusStateBz) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { suite.Require().ErrorContains(err, tc.expError.Error()) @@ -495,8 +493,7 @@ func (suite *WasmTestSuite) TestVerifyMembership() { err = lightClientModule.VerifyMembership(suite.chainA.GetContext(), clientID, proofHeight, 0, 0, proof, path, value) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) suite.Require().NoError(err) @@ -661,8 +658,7 @@ func (suite *WasmTestSuite) TestVerifyNonMembership() { err = lightClientModule.VerifyNonMembership(suite.chainA.GetContext(), clientID, proofHeight, 0, 0, proof, path) - expPass := tc.expError == nil - if expPass { + if tc.expError == nil { clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), clientID) suite.Require().NoError(err) @@ -772,8 +768,7 @@ func (suite *WasmTestSuite) TestVerifyClientMessage() { err = lightClientModule.VerifyClientMessage(suite.chainA.GetContext(), clientID, clientMsg) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().ErrorIs(err, tc.expErr) @@ -933,8 +928,7 @@ func (suite *WasmTestSuite) TestVerifyUpgradeAndUpdateState() { upgradedConsensusStateProof, ) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) // verify new client state and consensus state @@ -1530,8 +1524,7 @@ func (suite *WasmTestSuite) TestRecoverClient() { err = lightClientModule.RecoverClient(suite.chainA.GetContext(), subjectClientID, substituteClientID) - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { suite.Require().NoError(err) subjectClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), subjectClientID) diff --git a/modules/light-clients/08-wasm/types/msgs_test.go b/modules/light-clients/08-wasm/types/msgs_test.go index f7f377d3521..60feb9a1bd8 100644 --- a/modules/light-clients/08-wasm/types/msgs_test.go +++ b/modules/light-clients/08-wasm/types/msgs_test.go @@ -150,8 +150,7 @@ func TestMsgMigrateContractValidateBasic(t *testing.T) { tc := tc err := tc.msg.ValidateBasic() - expPass := tc.expErr == nil - if expPass { + if tc.expErr == nil { require.NoError(t, err) } else { require.ErrorIs(t, err, tc.expErr, tc.name) From 6201c799da3926c66cc8b8acbae220efd4a95603 Mon Sep 17 00:00:00 2001 From: meoaka3 Date: Sat, 21 Dec 2024 01:24:28 +0700 Subject: [PATCH 20/41] fix TestValidateControllerMetadata' (#7773) Co-authored-by: Gjermund Garaba --- .../types/metadata_test.go | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/metadata_test.go b/modules/apps/27-interchain-accounts/types/metadata_test.go index b408f98b0fc..4b6e0810c05 100644 --- a/modules/apps/27-interchain-accounts/types/metadata_test.go +++ b/modules/apps/27-interchain-accounts/types/metadata_test.go @@ -2,6 +2,7 @@ package types_test import ( "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types" + connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -142,12 +143,12 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", func() {}, - true, + nil, }, { "success with empty account address", @@ -161,7 +162,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - true, + nil, }, { "success with EncodingProto3JSON", @@ -175,7 +176,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - true, + nil, }, { "unsupported encoding format", @@ -189,7 +190,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidCodec, }, { "unsupported transaction type", @@ -203,7 +204,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: "invalid-tx-type", } }, - false, + types.ErrUnknownDataType, }, { "invalid controller connection", @@ -217,7 +218,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + connectiontypes.ErrInvalidConnection, }, { "invalid host connection", @@ -231,7 +232,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + connectiontypes.ErrInvalidConnection, }, { "invalid address", @@ -245,7 +246,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidAccountAddress, }, { "invalid version", @@ -259,7 +260,7 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidVersion, }, } @@ -282,10 +283,11 @@ func (suite *TypesTestSuite) TestValidateControllerMetadata() { metadata, ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) + suite.Require().ErrorIs(err, tc.expErr) } }) } From 18162f0197de8fb39efd6a1505d85d94c328333d Mon Sep 17 00:00:00 2001 From: meoikia Date: Sat, 21 Dec 2024 01:24:43 +0700 Subject: [PATCH 21/41] fix TestValidateBasic packet (#7775) Co-authored-by: Gjermund Garaba --- .../27-interchain-accounts/types/packet_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index d2bfa9a180d..041745e024b 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -11,7 +11,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { testCases := []struct { name string packetData types.InterchainAccountPacketData - expPass bool + expErr error }{ { "success", @@ -20,7 +20,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Data: []byte("data"), Memo: "memo", }, - true, + nil, }, { "success, empty memo", @@ -28,7 +28,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Type: types.EXECUTE_TX, Data: []byte("data"), }, - true, + nil, }, { "type unspecified", @@ -37,7 +37,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Data: []byte("data"), Memo: "memo", }, - false, + types.ErrInvalidOutgoingData, }, { "empty data", @@ -46,7 +46,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Data: []byte{}, Memo: "memo", }, - false, + types.ErrInvalidOutgoingData, }, { "nil data", @@ -55,7 +55,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Data: nil, Memo: "memo", }, - false, + types.ErrInvalidOutgoingData, }, { "memo too large", @@ -64,7 +64,7 @@ func (suite *TypesTestSuite) TestValidateBasic() { Data: []byte("data"), Memo: ibctesting.GenerateString(types.MaxMemoCharLength + 1), }, - false, + types.ErrInvalidOutgoingData, }, } @@ -75,10 +75,11 @@ func (suite *TypesTestSuite) TestValidateBasic() { err := tc.packetData.ValidateBasic() - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } From 1b06e2b416527168eaff5937dfdadab2288f9f34 Mon Sep 17 00:00:00 2001 From: solkorap7 Date: Sat, 21 Dec 2024 01:25:00 +0700 Subject: [PATCH 22/41] fix TestNewControllerPortID (#7777) Co-authored-by: Gjermund Garaba --- modules/apps/27-interchain-accounts/types/port_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/port_test.go b/modules/apps/27-interchain-accounts/types/port_test.go index 810224d98c0..0fc769ee015 100644 --- a/modules/apps/27-interchain-accounts/types/port_test.go +++ b/modules/apps/27-interchain-accounts/types/port_test.go @@ -15,13 +15,13 @@ func (suite *TypesTestSuite) TestNewControllerPortID() { name string malleate func() expValue string - expPass bool + expErr error }{ { "success", func() {}, types.ControllerPortPrefix + TestOwnerAddress, - true, + nil, }, { "invalid owner address", @@ -29,7 +29,7 @@ func (suite *TypesTestSuite) TestNewControllerPortID() { owner = " " }, "", - false, + types.ErrInvalidAccountAddress, }, } @@ -45,12 +45,13 @@ func (suite *TypesTestSuite) TestNewControllerPortID() { portID, err := types.NewControllerPortID(owner) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) suite.Require().Equal(tc.expValue, portID) } else { suite.Require().Error(err, tc.name) suite.Require().Empty(portID) + suite.Require().ErrorIs(err, tc.expErr) } }) } From 719bbaf310e0ed115f1940dd39f906108cff66c5 Mon Sep 17 00:00:00 2001 From: Noulodado Date: Fri, 20 Dec 2024 23:48:08 +0200 Subject: [PATCH 23/41] fix to use expected error (#7778) Co-authored-by: Gjermund Garaba --- .../types/metadata_test.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/metadata_test.go b/modules/apps/27-interchain-accounts/types/metadata_test.go index 4b6e0810c05..f96174c04d0 100644 --- a/modules/apps/27-interchain-accounts/types/metadata_test.go +++ b/modules/apps/27-interchain-accounts/types/metadata_test.go @@ -299,12 +299,12 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { testCases := []struct { name string malleate func() - expPass bool + expError error }{ { "success", func() {}, - true, + nil, }, { "success with empty account address", @@ -318,7 +318,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - true, + nil, }, { "success with EncodingProto3JSON", @@ -332,7 +332,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - true, + nil, }, { "unsupported encoding format", @@ -346,7 +346,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidCodec, }, { "unsupported transaction type", @@ -360,7 +360,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: "invalid-tx-type", } }, - false, + types.ErrUnknownDataType, }, { "invalid controller connection", @@ -374,7 +374,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + connectiontypes.ErrInvalidConnection, }, { "invalid host connection", @@ -388,7 +388,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + connectiontypes.ErrInvalidConnection, }, { "invalid address", @@ -402,7 +402,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidAccountAddress, }, { "invalid version", @@ -416,7 +416,7 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { TxType: types.TxTypeSDKMultiMsg, } }, - false, + types.ErrInvalidVersion, }, } @@ -439,10 +439,10 @@ func (suite *TypesTestSuite) TestValidateHostMetadata() { metadata, ) - if tc.expPass { + if tc.expError == nil { suite.Require().NoError(err, tc.name) } else { - suite.Require().Error(err, tc.name) + suite.Require().ErrorIs(err, tc.expError) } }) } From a89fbf693604094c2ce5443ba86fd9c80b5a32f3 Mon Sep 17 00:00:00 2001 From: solkorap7 Date: Sat, 21 Dec 2024 17:47:56 +0700 Subject: [PATCH 24/41] chore: fix TestParseClientIdentifier (#7779) --- modules/core/02-client/types/keys_test.go | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/modules/core/02-client/types/keys_test.go b/modules/core/02-client/types/keys_test.go index 3564c56d785..f031cf8b002 100644 --- a/modules/core/02-client/types/keys_test.go +++ b/modules/core/02-client/types/keys_test.go @@ -1,12 +1,14 @@ package types_test import ( + "errors" "math" "testing" "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" + host "github.com/cosmos/ibc-go/v9/modules/core/24-host" ) // tests ParseClientIdentifier and IsValidClientID @@ -16,32 +18,32 @@ func TestParseClientIdentifier(t *testing.T) { clientID string clientType string expSeq uint64 - expPass bool + expErr error }{ - {"valid 0", "tendermint-0", "tendermint", 0, true}, - {"valid 1", "tendermint-1", "tendermint", 1, true}, - {"valid solemachine", "solomachine-v1-1", "solomachine-v1", 1, true}, - {"valid large sequence", types.FormatClientIdentifier("tendermint", math.MaxUint64), "tendermint", math.MaxUint64, true}, - {"valid short client type", "t-0", "t", 0, true}, + {"valid 0", "tendermint-0", "tendermint", 0, nil}, + {"valid 1", "tendermint-1", "tendermint", 1, nil}, + {"valid solemachine", "solomachine-v1-1", "solomachine-v1", 1, nil}, + {"valid large sequence", types.FormatClientIdentifier("tendermint", math.MaxUint64), "tendermint", math.MaxUint64, nil}, + {"valid short client type", "t-0", "t", 0, nil}, // one above uint64 max - {"invalid uint64", "tendermint-18446744073709551616", "tendermint", 0, false}, + {"invalid uint64", "tendermint-18446744073709551616", "tendermint", 0, errors.New("failed to parse client identifier sequence")}, // uint64 == 20 characters - {"invalid large sequence", "tendermint-2345682193567182931243", "tendermint", 0, false}, - {"invalid newline in clientID", "tendermin\nt-1", "tendermin\nt", 0, false}, - {"invalid newline character before dash", "tendermint\n-1", "tendermint", 0, false}, - {"missing dash", "tendermint0", "tendermint", 0, false}, - {"blank id", " ", " ", 0, false}, - {"empty id", "", "", 0, false}, - {"negative sequence", "tendermint--1", "tendermint", 0, false}, - {"invalid format", "tendermint-tm", "tendermint", 0, false}, - {"empty clientype", " -100", "tendermint", 0, false}, - {"with in the middle tabs", "a\t\t\t-100", "tendermint", 0, false}, - {"leading tabs", "\t\t\ta-100", "tendermint", 0, false}, - {"with whitespace", " a-100", "tendermint", 0, false}, - {"leading hyphens", "-----a-100", "tendermint", 0, false}, - {"with slash", "tendermint/-100", "tendermint", 0, false}, - {"non-ASCII:: emoji", "🚨😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎-100", "tendermint", 0, false}, - {"non-ASCII:: others", "世界-100", "tendermint", 0, false}, + {"invalid large sequence", "tendermint-2345682193567182931243", "tendermint", 0, host.ErrInvalidID}, + {"invalid newline in clientID", "tendermin\nt-1", "tendermin\nt", 0, host.ErrInvalidID}, + {"invalid newline character before dash", "tendermint\n-1", "tendermint", 0, host.ErrInvalidID}, + {"missing dash", "tendermint0", "tendermint", 0, host.ErrInvalidID}, + {"blank id", " ", " ", 0, host.ErrInvalidID}, + {"empty id", "", "", 0, host.ErrInvalidID}, + {"negative sequence", "tendermint--1", "tendermint", 0, host.ErrInvalidID}, + {"invalid format", "tendermint-tm", "tendermint", 0, host.ErrInvalidID}, + {"empty clientype", " -100", "tendermint", 0, host.ErrInvalidID}, + {"with in the middle tabs", "a\t\t\t-100", "tendermint", 0, host.ErrInvalidID}, + {"leading tabs", "\t\t\ta-100", "tendermint", 0, host.ErrInvalidID}, + {"with whitespace", " a-100", "tendermint", 0, host.ErrInvalidID}, + {"leading hyphens", "-----a-100", "tendermint", 0, host.ErrInvalidID}, + {"with slash", "tendermint/-100", "tendermint", 0, host.ErrInvalidID}, + {"non-ASCII:: emoji", "🚨😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎😎-100", "tendermint", 0, host.ErrInvalidID}, + {"non-ASCII:: others", "世界-100", "tendermint", 0, host.ErrInvalidID}, } for _, tc := range testCases { @@ -51,7 +53,7 @@ func TestParseClientIdentifier(t *testing.T) { valid := types.IsValidClientID(tc.clientID) require.Equal(t, tc.expSeq, seq, tc.clientID) - if tc.expPass { + if tc.expErr == nil { require.NoError(t, err, tc.name) require.True(t, valid) require.Equal(t, tc.clientType, clientType) @@ -59,6 +61,7 @@ func TestParseClientIdentifier(t *testing.T) { require.Error(t, err, tc.name, tc.clientID) require.False(t, valid) require.Equal(t, "", clientType) + require.ErrorContains(t, err, tc.expErr.Error()) } }) } From a3239a25b5a57aed76e49d4cd6c60c34a4991522 Mon Sep 17 00:00:00 2001 From: meoaka3 Date: Sat, 21 Dec 2024 18:16:36 +0700 Subject: [PATCH 25/41] fix TestSerializeAndDeserializeCosmosTx (#7780) Co-authored-by: Gjermund Garaba --- .../types/codec_test.go | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index 854f0dca5bf..fd0f0f9a11c 100644 --- a/modules/apps/27-interchain-accounts/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/types/codec_test.go @@ -53,7 +53,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "single msg", @@ -66,7 +66,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { }, } }, - true, + nil, }, { "multiple msgs, same types", @@ -84,7 +84,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { }, } }, - true, + nil, }, { "success: multiple msgs, different types", @@ -102,7 +102,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { }, } }, - true, + nil, }, { "success: msg with nested any", @@ -122,7 +122,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { }, } }, - true, + nil, }, { "success: msg with nested array of any", @@ -170,14 +170,14 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { msgs = []proto.Message{propMsg} }, - true, + nil, }, { "success: empty messages", func() { msgs = []proto.Message{} }, - true, + nil, }, { "failure: unregistered msg type", @@ -189,7 +189,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { expSerializeErrorStrings = []string{"NO_ERROR_EXPECTED", "cannot marshal CosmosTx with proto3 json"} expDeserializeErrorStrings = []string{"cannot unmarshal CosmosTx with protobuf", "cannot unmarshal CosmosTx with proto3 json"} }, - false, + ibcerrors.ErrInvalidType, }, { "failure: multiple unregistered msg types", @@ -203,7 +203,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { expSerializeErrorStrings = []string{"NO_ERROR_EXPECTED", "cannot marshal CosmosTx with proto3 json"} expDeserializeErrorStrings = []string{"cannot unmarshal CosmosTx with protobuf", "cannot unmarshal CosmosTx with proto3 json"} }, - false, + ibcerrors.ErrInvalidType, }, { "failure: nested unregistered msg", @@ -223,7 +223,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { expSerializeErrorStrings = []string{"NO_ERROR_EXPECTED", "cannot marshal CosmosTx with proto3 json"} expDeserializeErrorStrings = []string{"cannot unmarshal CosmosTx with protobuf", "cannot unmarshal CosmosTx with proto3 json"} }, - false, + ibcerrors.ErrInvalidType, }, { "failure: nested array of unregistered msg", @@ -248,7 +248,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { expSerializeErrorStrings = []string{"NO_ERROR_EXPECTED", "cannot marshal CosmosTx with proto3 json"} expDeserializeErrorStrings = []string{"cannot unmarshal CosmosTx with protobuf", "cannot unmarshal CosmosTx with proto3 json"} }, - false, + ibcerrors.ErrInvalidType, }, } @@ -259,8 +259,9 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { suite.Run(tc.name, func() { tc.malleate() + expPass := tc.expErr == nil bz, err := types.SerializeCosmosTx(suite.chainA.Codec, msgs, encoding) - if encoding == types.EncodingProto3JSON && !tc.expPass { + if encoding == types.EncodingProto3JSON && !expPass { suite.Require().Error(err, tc.name) suite.Require().Contains(err.Error(), expSerializeErrorStrings[1], tc.name) } else { @@ -268,14 +269,15 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { } deserializedMsgs, err := types.DeserializeCosmosTx(suite.chainA.Codec, bz, encoding) - if tc.expPass { + if expPass { suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) suite.Require().Contains(err.Error(), expDeserializeErrorStrings[i], tc.name) + suite.Require().ErrorIs(err, tc.expErr) } - if tc.expPass { + if expPass { for i, msg := range msgs { // We're using proto.CompactTextString() for comparison instead of suite.Require().Equal() or proto.Equal() // for two main reasons: From 0a7756f6e7c1bc52dcaea0fead81b132f5562d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=92?= <47621124+ronething-bot@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:16:47 +0800 Subject: [PATCH 26/41] docs: update integration guide for ibc-go v7 and v8 (#7781) --- docs/versioned_docs/version-v7.8.x/01-ibc/02-integration.md | 2 +- docs/versioned_docs/version-v8.5.x/01-ibc/02-integration.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/versioned_docs/version-v7.8.x/01-ibc/02-integration.md b/docs/versioned_docs/version-v7.8.x/01-ibc/02-integration.md index f82ee31405c..c15f58da404 100644 --- a/docs/versioned_docs/version-v7.8.x/01-ibc/02-integration.md +++ b/docs/versioned_docs/version-v7.8.x/01-ibc/02-integration.md @@ -47,7 +47,7 @@ The following code example shows how to register the existing `ibctm.AppModuleBa import ( ... -+ ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint" ++ ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ... ) diff --git a/docs/versioned_docs/version-v8.5.x/01-ibc/02-integration.md b/docs/versioned_docs/version-v8.5.x/01-ibc/02-integration.md index 5a3ea531ae1..7468c45907e 100644 --- a/docs/versioned_docs/version-v8.5.x/01-ibc/02-integration.md +++ b/docs/versioned_docs/version-v8.5.x/01-ibc/02-integration.md @@ -46,7 +46,7 @@ The following code example shows how to register the existing `ibctm.AppModuleBa import ( ... // highlight-next-line -+ ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint" ++ ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ... ) From 3e7348ded0f1e6a4476ac242c24d362ef65516c9 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:36:25 +0700 Subject: [PATCH 27/41] Combine functions TestGetSourceCallbackDataTransfer and TestGetDestCallbackDataTransfer (#7694) * Combine get dest and source callback tests * lint --- .../apps/callbacks/types/callbacks_test.go | 218 ++++++++---------- 1 file changed, 101 insertions(+), 117 deletions(-) diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index 82e73172fa0..26dc099edfd 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -13,6 +13,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" ibcmock "github.com/cosmos/ibc-go/v9/testing/mock" @@ -567,154 +568,134 @@ type bytesProvider interface { GetBytes() []byte } -func (s *CallbacksTypesTestSuite) TestGetSourceCallbackDataTransfer() { +func (s *CallbacksTypesTestSuite) TestGetDestSourceCallbackDataTransfer() { sender := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() receiver := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - - testCases := []struct { - name string + var ( packetData bytesProvider expCallbackData types.CallbackData - malleate func() + ) + + expSrcCallBack := types.CallbackData{ + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, + } + + expDstCallBack := types.CallbackData{ + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, + } + + testCases := []struct { + name string + malleate func() + callbackFn func( + ctx sdk.Context, + packetDataUnmarshaler porttypes.PacketDataUnmarshaler, + packet channeltypes.Packet, + maxGas uint64, + ) (types.CallbackData, error) + getSrc bool }{ { - "success: v1", - transfertypes.FungibleTokenPacketData{ - Denom: ibctesting.TestCoin.Denom, - Amount: ibctesting.TestCoin.Amount.String(), - Sender: sender, - Receiver: receiver, - Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), - }, - types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, - ApplicationVersion: transfertypes.V1, - }, + "success: src_callback v1", func() { + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), + } + + expCallbackData = expSrcCallBack + s.path.EndpointA.ChannelConfig.Version = transfertypes.V1 s.path.EndpointA.ChannelConfig.PortID = transfertypes.ModuleName s.path.EndpointB.ChannelConfig.Version = transfertypes.V1 s.path.EndpointB.ChannelConfig.PortID = transfertypes.ModuleName }, + types.GetSourceCallbackData, + true, }, { - "success: v2", - transfertypes.FungibleTokenPacketDataV2{ - Tokens: transfertypes.Tokens{ - { - Denom: transfertypes.NewDenom(ibctesting.TestCoin.Denom), - Amount: ibctesting.TestCoin.Amount.String(), - }, - }, - Sender: sender, - Receiver: receiver, - Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), - }, - types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, - ApplicationVersion: transfertypes.V2, - }, + "success: src_callback v2", func() { + packetData = transfertypes.FungibleTokenPacketDataV2{ + Tokens: transfertypes.Tokens{ + { + Denom: transfertypes.NewDenom(ibctesting.TestCoin.Denom), + Amount: ibctesting.TestCoin.Amount.String(), + }, + }, + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), + } + + expCallbackData = expSrcCallBack + expCallbackData.ApplicationVersion = transfertypes.V2 + s.path.EndpointA.ChannelConfig.Version = transfertypes.V2 s.path.EndpointA.ChannelConfig.PortID = transfertypes.ModuleName s.path.EndpointB.ChannelConfig.Version = transfertypes.V2 s.path.EndpointB.ChannelConfig.PortID = transfertypes.ModuleName }, + types.GetSourceCallbackData, + true, }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - s.SetupTest() - - tc.malleate() - - packetDataBytes := tc.packetData.GetBytes() - - transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) - s.Require().True(ok) - - packetUnmarshaler, ok := transferStack.(types.CallbacksCompatibleModule) - s.Require().True(ok) - - s.path.Setup() - - gasMeter := storetypes.NewGasMeter(2_000_000) - ctx := s.chainA.GetContext().WithGasMeter(gasMeter) - packet := channeltypes.NewPacket(packetDataBytes, 0, transfertypes.PortID, s.path.EndpointA.ChannelID, transfertypes.PortID, s.path.EndpointB.ChannelID, clienttypes.ZeroHeight(), 0) - callbackData, err := types.GetSourceCallbackData(ctx, packetUnmarshaler, packet, 1_000_000) - s.Require().NoError(err) - s.Require().Equal(tc.expCallbackData, callbackData) - }) - } -} - -func (s *CallbacksTypesTestSuite) TestGetDestCallbackDataTransfer() { - sender := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - receiver := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - - testCases := []struct { - name string - packetData bytesProvider - expCallbackdata types.CallbackData - malleate func() - }{ { - "success: v1", - transfertypes.FungibleTokenPacketData{ - Denom: ibctesting.TestCoin.Denom, - Amount: ibctesting.TestCoin.Amount.String(), - Sender: sender, - Receiver: receiver, - Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), - }, - types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, - ApplicationVersion: transfertypes.V1, - }, + "success: dest_callback v1", func() { + packetData = transfertypes.FungibleTokenPacketData{ + Denom: ibctesting.TestCoin.Denom, + Amount: ibctesting.TestCoin.Amount.String(), + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), + } + + expCallbackData = expDstCallBack + s.path.EndpointA.ChannelConfig.Version = transfertypes.V1 s.path.EndpointA.ChannelConfig.PortID = transfertypes.ModuleName s.path.EndpointB.ChannelConfig.Version = transfertypes.V1 s.path.EndpointB.ChannelConfig.PortID = transfertypes.ModuleName }, + types.GetDestCallbackData, + false, }, { - "success: v2", - transfertypes.FungibleTokenPacketDataV2{ - Tokens: transfertypes.Tokens{ - { - Denom: transfertypes.NewDenom(ibctesting.TestCoin.Denom), - Amount: ibctesting.TestCoin.Amount.String(), - }, - }, - Sender: sender, - Receiver: receiver, - Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), - }, - types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, - ApplicationVersion: transfertypes.V2, - }, + "success: dest_callback v2", func() { + packetData = transfertypes.FungibleTokenPacketDataV2{ + Tokens: transfertypes.Tokens{ + { + Denom: transfertypes.NewDenom(ibctesting.TestCoin.Denom), + Amount: ibctesting.TestCoin.Amount.String(), + }, + }, + Sender: sender, + Receiver: receiver, + Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), + } + + expCallbackData = expDstCallBack + expCallbackData.ApplicationVersion = transfertypes.V2 + s.path.EndpointA.ChannelConfig.Version = transfertypes.V2 s.path.EndpointA.ChannelConfig.PortID = transfertypes.ModuleName s.path.EndpointB.ChannelConfig.Version = transfertypes.V2 s.path.EndpointB.ChannelConfig.PortID = transfertypes.ModuleName }, + types.GetDestCallbackData, + false, }, } @@ -725,8 +706,6 @@ func (s *CallbacksTypesTestSuite) TestGetDestCallbackDataTransfer() { tc.malleate() - packetDataBytes := tc.packetData.GetBytes() - transferStack, ok := s.chainA.App.GetIBCKeeper().PortKeeper.Route(transfertypes.ModuleName) s.Require().True(ok) @@ -737,10 +716,15 @@ func (s *CallbacksTypesTestSuite) TestGetDestCallbackDataTransfer() { gasMeter := storetypes.NewGasMeter(2_000_000) ctx := s.chainA.GetContext().WithGasMeter(gasMeter) - packet := channeltypes.NewPacket(packetDataBytes, 0, transfertypes.PortID, s.path.EndpointB.ChannelID, transfertypes.PortID, s.path.EndpointA.ChannelID, clienttypes.ZeroHeight(), 0) - callbackData, err := types.GetDestCallbackData(ctx, packetUnmarshaler, packet, 1_000_000) + var packet channeltypes.Packet + if tc.getSrc { + packet = channeltypes.NewPacket(packetData.GetBytes(), 0, transfertypes.PortID, s.path.EndpointA.ChannelID, transfertypes.PortID, s.path.EndpointB.ChannelID, clienttypes.ZeroHeight(), 0) + } else { + packet = channeltypes.NewPacket(packetData.GetBytes(), 0, transfertypes.PortID, s.path.EndpointB.ChannelID, transfertypes.PortID, s.path.EndpointA.ChannelID, clienttypes.ZeroHeight(), 0) + } + callbackData, err := tc.callbackFn(ctx, packetUnmarshaler, packet, 1_000_000) s.Require().NoError(err) - s.Require().Equal(tc.expCallbackdata, callbackData) + s.Require().Equal(expCallbackData, callbackData) }) } } From 376873672db2b866577bd9862719d224d59a89c4 Mon Sep 17 00:00:00 2001 From: "fuder.eth" <139509124+vtjl10@users.noreply.github.com> Date: Sun, 22 Dec 2024 23:48:03 +0200 Subject: [PATCH 28/41] Update 07-v5-to-v6.md (#7784) --- docs/docs/05-migrations/07-v5-to-v6.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/05-migrations/07-v5-to-v6.md b/docs/docs/05-migrations/07-v5-to-v6.md index 4fc777e6cd9..f2e77604fab 100644 --- a/docs/docs/05-migrations/07-v5-to-v6.md +++ b/docs/docs/05-migrations/07-v5-to-v6.md @@ -198,10 +198,10 @@ func DefaultParams() Params { `SerializeCosmosTx` takes in a `[]proto.Message` instead of `[]sdk.Message`. This allows for the serialization of proto messages without requiring the fulfillment of the `sdk.Msg` interface. -The `27-interchain-accounts` genesis types have been moved to their own package: `modules/apps/27-interchain-acccounts/genesis/types`. +The `27-interchain-accounts` genesis types have been moved to their own package: `modules/apps/27-interchain-accounts/genesis/types`. This change facilitates the addition of the ICS27 controller submodule `MsgServer` and avoids cyclic imports. This should have minimal disruption to chain developers integrating `27-interchain-accounts`. -The ICS27 host submodule `NewKeeper` function in `modules/apps/27-interchain-acccounts/host/keeper` now includes an additional parameter of type `ICS4Wrapper`. +The ICS27 host submodule `NewKeeper` function in `modules/apps/27-interchain-accounts/host/keeper` now includes an additional parameter of type `ICS4Wrapper`. This provides the host submodule with the ability to correctly unwrap channel versions in the event of a channel reopening handshake. ```diff From 6c415051b69c3d01706fc1a1957293cb819e955a Mon Sep 17 00:00:00 2001 From: Tristav <124001124+Pricstas@users.noreply.github.com> Date: Sun, 22 Dec 2024 22:48:47 +0100 Subject: [PATCH 29/41] fix: Typographical Errors (#7786) * typos groups_test.go * typos diagnostics.go * typos callbacks_test.go * typos export.go * typos genesis.go * typos height.go * typos validate.go * typos export.go * typos genesis.go * typos export.go --- e2e/tests/interchain_accounts/groups_test.go | 2 +- e2e/testsuite/diagnostics/diagnostics.go | 2 +- modules/apps/callbacks/callbacks_test.go | 2 +- modules/apps/callbacks/testing/simapp/export.go | 2 +- modules/apps/callbacks/testing/simapp/genesis.go | 2 +- modules/core/02-client/types/height.go | 2 +- modules/core/24-host/validate.go | 2 +- modules/light-clients/08-wasm/testing/simapp/export.go | 2 +- modules/light-clients/08-wasm/testing/simapp/genesis.go | 2 +- simapp/export.go | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/e2e/tests/interchain_accounts/groups_test.go b/e2e/tests/interchain_accounts/groups_test.go index e6e113e6c09..1019fbbb253 100644 --- a/e2e/tests/interchain_accounts/groups_test.go +++ b/e2e/tests/interchain_accounts/groups_test.go @@ -44,7 +44,7 @@ const ( // where members can start sending MsgExec. This means that the window for // sending a MsgExec transaction is: // `[ submission + min_execution_period ; submission + voting_period + max_execution_period]` - // where max_execution_period is a app-specific config, defined in the keeper. + // where max_execution_period is an app-specific config, defined in the keeper. // If not set, min_execution_period will default to 0. DefaultMinExecutionPeriod = time.Duration(0) diff --git a/e2e/testsuite/diagnostics/diagnostics.go b/e2e/testsuite/diagnostics/diagnostics.go index e00d670e14d..958e3a8f428 100644 --- a/e2e/testsuite/diagnostics/diagnostics.go +++ b/e2e/testsuite/diagnostics/diagnostics.go @@ -99,7 +99,7 @@ func Collect(t *testing.T, dc *dockerclient.Client, debugModeEnabled bool, suite } } -// getContainerName returns a either the ID of the container or stripped down human-readable +// getContainerName returns an either the ID of the container or stripped down human-readable // version of the name if the name is non-empty. // // Note: You should still always use the ID when interacting with the docker client. diff --git a/modules/apps/callbacks/callbacks_test.go b/modules/apps/callbacks/callbacks_test.go index 21a1a07b78d..69c77b7ab0b 100644 --- a/modules/apps/callbacks/callbacks_test.go +++ b/modules/apps/callbacks/callbacks_test.go @@ -112,7 +112,7 @@ func (s *CallbacksTestSuite) SetupICATest() string { s.path.SetupConnections() icaOwner := s.chainA.SenderAccount.GetAddress().String() - // ICAVersion defines a interchain accounts version string + // ICAVersion defines an interchain accounts version string icaVersion := icatypes.NewDefaultMetadataString(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID) icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner) s.Require().NoError(err) diff --git a/modules/apps/callbacks/testing/simapp/export.go b/modules/apps/callbacks/testing/simapp/export.go index 45642fa1064..f6fe79c8649 100644 --- a/modules/apps/callbacks/testing/simapp/export.go +++ b/modules/apps/callbacks/testing/simapp/export.go @@ -57,7 +57,7 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false - // check if there is a allowed address list + // check if there is an allowed address list if len(jailAllowedAddrs) > 0 { applyAllowedAddrs = true } diff --git a/modules/apps/callbacks/testing/simapp/genesis.go b/modules/apps/callbacks/testing/simapp/genesis.go index 69fa46b90ef..19328b3f2e0 100644 --- a/modules/apps/callbacks/testing/simapp/genesis.go +++ b/modules/apps/callbacks/testing/simapp/genesis.go @@ -5,7 +5,7 @@ import ( ) // GenesisState of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. +// messages key'd by an identifier string. // The identifier is used to determine which module genesis information belongs // to so it may be appropriately routed during init chain. // Within this application default genesis information is retrieved from diff --git a/modules/core/02-client/types/height.go b/modules/core/02-client/types/height.go index 82ce3a17a9c..6a61c0bf35c 100644 --- a/modules/core/02-client/types/height.go +++ b/modules/core/02-client/types/height.go @@ -166,7 +166,7 @@ func SetRevisionNumber(chainID string, revision uint64) (string, error) { return strings.Join(splitStr, "-"), nil } -// ParseChainID is a utility function that returns an revision number from the given ChainID. +// ParseChainID is a utility function that returns a revision number from the given ChainID. // ParseChainID attempts to parse a chain id in the format: `{chainID}-{revision}` // and return the revisionnumber as a uint64. // If the chainID is not in the expected format, a default revision value of 0 is returned. diff --git a/modules/core/24-host/validate.go b/modules/core/24-host/validate.go index 8802099abb9..3ba0f88847c 100644 --- a/modules/core/24-host/validate.go +++ b/modules/core/24-host/validate.go @@ -87,7 +87,7 @@ func PortIdentifierValidator(id string) error { return defaultIdentifierValidator(id, 2, DefaultMaxPortCharacterLength) } -// NewPathValidator takes in a Identifier Validator function and returns +// NewPathValidator takes in an Identifier Validator function and returns // a Path Validator function which requires path to consist of `/`-separated valid identifiers, // where a valid identifier is between 1-64 characters, contains only alphanumeric and some allowed // special characters (see IsValidID), and satisfies the custom `idValidator` function. diff --git a/modules/light-clients/08-wasm/testing/simapp/export.go b/modules/light-clients/08-wasm/testing/simapp/export.go index 45642fa1064..f6fe79c8649 100644 --- a/modules/light-clients/08-wasm/testing/simapp/export.go +++ b/modules/light-clients/08-wasm/testing/simapp/export.go @@ -57,7 +57,7 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false - // check if there is a allowed address list + // check if there is an allowed address list if len(jailAllowedAddrs) > 0 { applyAllowedAddrs = true } diff --git a/modules/light-clients/08-wasm/testing/simapp/genesis.go b/modules/light-clients/08-wasm/testing/simapp/genesis.go index 2667b97a4fc..d71d15f4970 100644 --- a/modules/light-clients/08-wasm/testing/simapp/genesis.go +++ b/modules/light-clients/08-wasm/testing/simapp/genesis.go @@ -5,7 +5,7 @@ import ( ) // The genesis state of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. +// messages key'd by an identifier string. // The identifier is used to determine which module genesis information belongs // to so it may be appropriately routed during init chain. // Within this application default genesis information is retrieved from diff --git a/simapp/export.go b/simapp/export.go index 45642fa1064..f6fe79c8649 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -57,7 +57,7 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false - // check if there is a allowed address list + // check if there is an allowed address list if len(jailAllowedAddrs) > 0 { applyAllowedAddrs = true } From 37dce93c2dd742c7c11cc94ed14de24f9d66d2a0 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Mon, 23 Dec 2024 15:45:39 +0100 Subject: [PATCH 30/41] chore: update codeowners (#7793) --- .github/CODEOWNERS | 51 ++-------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f7f3404256b..7310f39e4cf 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,52 +1,5 @@ # CODEOWNERS: https://help.github.com/articles/about-codeowners/ -* @AdityaSripal @damiannolan @gjermundgaraba - -# Our appreciation and gratitude to past code owners: @fedekunze @seantking @tmsdkeys @charleenfei @crodriguezvega @colin-axner @chatton @bznein @DimitrisJim - -# Order is important; the last matching pattern takes the most -# precedence. When someone opens a pull request that only -# modifies 27-interchain-accounts files, only the interchain account owners -# and not the global owner(s) will be requested for a review. - -# CODEOWNERS for the CODEOWNER file - -/.github/CODEOWNERS @AdityaSripal @damiannolan - -# CODEOWNERS for the core IBC module - -/modules/core/ @AdityaSripal @damiannolan -/proto/ibc/core/ @AdityaSripal @damiannolan - -# CODEOWNERS for the light-clients - -/modules/light-clients/ @AdityaSripal @damiannolan -/proto/ibc/lightclients/ @AdityaSripal @damiannolan - -# CODEOWNERS for 08-wasm light client module - -/modules/light-clients/08-wasm/ @AdityaSripal @damiannolan @srdtrk - -# CODEOWNERS for ICS 20 - -/modules/apps/transfer/ @AdityaSripal @damiannolan -/proto/ibc/applications/transfer/ @AdityaSripal @damiannolan - -# CODEOWNERS for interchain-accounts module - -/modules/apps/27-interchain-accounts/ @AdityaSripal @damiannolan -/proto/ibc/applications/interchain_accounts/ @AdityaSripal @damiannolan - -# CODEOWNERS for fee module - -/modules/apps/29-fee/ @AdityaSripal @damiannolan -/proto/ibc/applications/fee/ @AdityaSripal @damiannolan - -# CODEOWNERS for callbacks middleware - -/modules/apps/callbacks/ @AdityaSripal @damiannolan @srdtrk - -# CODEOWNERS for docs - -/docs/ @AdityaSripal @damiannolan @srdtrk +* @AdityaSripal @gjermundgaraba @srdtrk +# Our appreciation and gratitude to past code owners: @fedekunze @seantking @tmsdkeys @charleenfei @crodriguezvega @colin-axner @chatton @bznein @DimitrisJim @damiannolan From e10bbbc47fb70e138a3369902d18586b3da95800 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Mon, 23 Dec 2024 15:58:14 +0100 Subject: [PATCH 31/41] chore: fix and update linter (#7792) * update linter version * lint and update linter in all ci --- .github/workflows/callbacks.yml | 2 +- .github/workflows/e2emodule.yml | 2 +- .github/workflows/golangci-feature.yml | 2 +- .github/workflows/golangci.yml | 2 +- .github/workflows/wasm-client.yml | 2 +- modules/apps/29-fee/keeper/grpc_query.go | 6 +++--- modules/core/04-channel/keeper/keeper.go | 10 +++++----- modules/core/24-host/validate.go | 6 +++--- modules/light-clients/07-tendermint/client_state.go | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/callbacks.yml b/.github/workflows/callbacks.yml index adf1b777e56..d4e13cc5316 100644 --- a/.github/workflows/callbacks.yml +++ b/.github/workflows/callbacks.yml @@ -23,7 +23,7 @@ jobs: fetch-depth: 0 - uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.60 + version: v1.62 only-new-issues: true args: --timeout 5m working-directory: modules/apps/callbacks diff --git a/.github/workflows/e2emodule.yml b/.github/workflows/e2emodule.yml index 5d57178b3d1..0a39029ac76 100644 --- a/.github/workflows/e2emodule.yml +++ b/.github/workflows/e2emodule.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: 0 - uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.60 + version: v1.62 only-new-issues: true args: --timeout 5m working-directory: e2e/ diff --git a/.github/workflows/golangci-feature.yml b/.github/workflows/golangci-feature.yml index f3d8b9f1e60..f66d2ddb1ba 100644 --- a/.github/workflows/golangci-feature.yml +++ b/.github/workflows/golangci-feature.yml @@ -29,6 +29,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.60 + version: v1.62 only-new-issues: true args: --timeout 10m diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index ccec7ff787f..1e22051640e 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -25,6 +25,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.60 + version: v1.62 only-new-issues: true args: --timeout 10m diff --git a/.github/workflows/wasm-client.yml b/.github/workflows/wasm-client.yml index f947cac3b79..5e669b2afab 100644 --- a/.github/workflows/wasm-client.yml +++ b/.github/workflows/wasm-client.yml @@ -22,7 +22,7 @@ jobs: fetch-depth: 0 - uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.60 + version: v1.62 only-new-issues: true args: --timeout 10m working-directory: modules/light-clients/08-wasm diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 1c0b4317185..a2e9fb92eb1 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -118,7 +118,7 @@ func (k Keeper) TotalRecvFees(ctx context.Context, req *types.QueryTotalRecvFees feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) if !found { - return nil, status.Errorf( + return nil, status.Error( codes.NotFound, errorsmod.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), ) @@ -142,7 +142,7 @@ func (k Keeper) TotalAckFees(ctx context.Context, req *types.QueryTotalAckFeesRe feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) if !found { - return nil, status.Errorf( + return nil, status.Error( codes.NotFound, errorsmod.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), ) @@ -166,7 +166,7 @@ func (k Keeper) TotalTimeoutFees(ctx context.Context, req *types.QueryTotalTimeo feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) if !found { - return nil, status.Errorf( + return nil, status.Error( codes.NotFound, errorsmod.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), ) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index c14f6aa49c8..527cd10007d 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -369,7 +369,7 @@ func (k *Keeper) GetAllPacketAckSeqs(ctx context.Context) (seqs []types.PacketSe func (k *Keeper) IteratePacketCommitment(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketCommitmentPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketCommitments returns all stored PacketCommitments objects. @@ -388,7 +388,7 @@ func (k *Keeper) GetAllPacketCommitments(ctx context.Context) (commitments []typ func (k *Keeper) IteratePacketCommitmentAtChannel(ctx context.Context, portID, channelID string, cb func(_, _ string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, host.PacketCommitmentPrefixKey(portID, channelID)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified @@ -408,7 +408,7 @@ func (k *Keeper) GetAllPacketCommitmentsAtChannel(ctx context.Context, portID, c func (k *Keeper) IteratePacketReceipt(ctx context.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketReceipts returns all stored PacketReceipt objects. @@ -427,7 +427,7 @@ func (k *Keeper) GetAllPacketReceipts(ctx context.Context) (receipts []types.Pac func (k *Keeper) IteratePacketAcknowledgement(ctx context.Context, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)) iterator := storetypes.KVStorePrefixIterator(store, []byte(host.KeyPacketAckPrefix)) - k.iterateHashes(ctx, iterator, cb) + k.iterateHashes(iterator, cb) } // GetAllPacketAcks returns all stored PacketAcknowledgements objects. @@ -688,7 +688,7 @@ func (k *Keeper) GetParams(ctx context.Context) types.Params { } // common functionality for IteratePacketCommitment and IteratePacketAcknowledgement -func (k *Keeper) iterateHashes(ctx context.Context, iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { +func (k *Keeper) iterateHashes(iterator db.Iterator, cb func(portID, channelID string, sequence uint64, hash []byte) bool) { defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() }) for ; iterator.Valid(); iterator.Next() { diff --git a/modules/core/24-host/validate.go b/modules/core/24-host/validate.go index 3ba0f88847c..fb83a83542c 100644 --- a/modules/core/24-host/validate.go +++ b/modules/core/24-host/validate.go @@ -36,7 +36,7 @@ var IsValidID = regexp.MustCompile(`^[a-zA-Z0-9\.\_\+\-\#\[\]\<\>]+$`).MatchStri // ValidateFn function type to validate path and identifier bytestrings type ValidateFn func(string) error -func defaultIdentifierValidator(id string, min, max int) error { +func defaultIdentifierValidator(id string, minLength, maxLength int) error { if strings.TrimSpace(id) == "" { return errorsmod.Wrap(ErrInvalidID, "identifier cannot be blank") } @@ -45,8 +45,8 @@ func defaultIdentifierValidator(id string, min, max int) error { return errorsmod.Wrapf(ErrInvalidID, "identifier %s cannot contain separator '/'", id) } // valid id must fit the length requirements - if len(id) < min || len(id) > max { - return errorsmod.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), min, max) + if len(id) < minLength || len(id) > maxLength { + return errorsmod.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), minLength, maxLength) } // valid id must contain only alphanumeric characters and some allowed symbols. if !IsValidID(id) { diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 89ab21128d7..9261ed81c09 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -125,7 +125,7 @@ func (cs ClientState) Validate() error { } if err := light.ValidateTrustLevel(cs.TrustLevel.ToTendermint()); err != nil { - return errorsmod.Wrapf(ErrInvalidTrustLevel, err.Error()) + return errorsmod.Wrap(ErrInvalidTrustLevel, err.Error()) } if cs.TrustingPeriod <= 0 { return errorsmod.Wrap(ErrInvalidTrustingPeriod, "trusting period must be greater than zero") From 6909b27d3c3721bdf27b032a52f38628180985fb Mon Sep 17 00:00:00 2001 From: Noulodado Date: Mon, 23 Dec 2024 20:17:56 +0200 Subject: [PATCH 32/41] Use wrap instead of wrapf (#7796) --- modules/light-clients/07-tendermint/client_state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 9261ed81c09..f400f4cbf47 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -143,7 +143,7 @@ func (cs ClientState) Validate() error { "latest height revision number must match chain id revision number (%d != %d)", cs.LatestHeight.RevisionNumber, clienttypes.ParseChainID(cs.ChainId)) } if cs.LatestHeight.RevisionHeight == 0 { - return errorsmod.Wrapf(ErrInvalidHeaderHeight, "tendermint client's latest height revision height cannot be zero") + return errorsmod.Wrap(ErrInvalidHeaderHeight, "tendermint client's latest height revision height cannot be zero") } if cs.TrustingPeriod >= cs.UnbondingPeriod { return errorsmod.Wrapf( From e4da87607d34a350cc57d4c1cc267ad49e13d3cf Mon Sep 17 00:00:00 2001 From: solkorap7 Date: Tue, 24 Dec 2024 01:19:10 +0700 Subject: [PATCH 33/41] lint unused (#7795) --- modules/light-clients/07-tendermint/client_state_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/light-clients/07-tendermint/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go index 1b962873a4c..74935533c7d 100644 --- a/modules/light-clients/07-tendermint/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -21,7 +21,6 @@ func (suite *TendermintTestSuite) TestValidate() { name string clientState *ibctm.ClientState expErr error - expPass bool }{ { name: "valid client", From 805894dd275423eb05074d78a79350be03298358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=B8llie?= Date: Mon, 23 Dec 2024 21:24:19 +0000 Subject: [PATCH 34/41] chore: Update AI Bot to Unified Bot (#7788) This commit changes the AI bot integration from the IBC-specific bot to the integration that understands the full stack - which has been performing very well in other integration locations. It also adds a logo for InterchainGPT, and changes the disclaimer text to reflect. --- docs/docusaurus.config.js | 6 +++--- docs/static/img/spirograph-white.svg | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 docs/static/img/spirograph-white.svg diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index e953a05c3c8..ce3178bd125 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -353,19 +353,19 @@ const config = { scripts: [ { src: "https://widget.kapa.ai/kapa-widget.bundle.js", - "data-website-id": "806aa1dc-0d46-4563-a8b8-880eecac59f1", + "data-website-id": "33cd677e-ea9e-437e-a3c1-dbacbe03afc1", "data-project-name": "Interchain", "data-user-analytics-fingerprint-enabled": "true", "data-project-color": "#1878FF", "data-modal-title": "IBC Docs AI", - "data-modal-disclaimer": "This is a custom LLM for the Inter-Blockchain Communication Protocol in Golang (ibc-go). It is trained on the IBC developer documentation, code base, and resources. Answers are AI-generated. Please use your best judgment before implementing. The bot is not trained on documentation, code, or resources for the Cosmos SDK, CometBFT, CosmJS, CosmWasm, or interchain ecosystem blockchains. Please refer to those specific documentation sites for answers to those questions.", + "data-modal-disclaimer": "This is a custom LLM for the Interchain Stack with access to developer documentation and resources across the core Cosmos components. Please note that answers are generated by an AI so please use your best judgement before implementing.", "data-modal-ask-ai-input-placeholder": "Ask me a question about IBC...", "data-modal-disclaimer-text-color": "#000000", "data-modal-disclaimer-font-size": "14px", "data-modal-image": "/img/black-ibc-logo-400x400.svg", "data-project-logo": - "/img/white-ibc-logo-400x400.svg", + "/img/spirograph-white.svg", async: true, }, ], diff --git a/docs/static/img/spirograph-white.svg b/docs/static/img/spirograph-white.svg new file mode 100644 index 00000000000..f4957303261 --- /dev/null +++ b/docs/static/img/spirograph-white.svg @@ -0,0 +1,5 @@ + + + From 2ce62a4c27971c46996dcc1a54c65156e58bcae1 Mon Sep 17 00:00:00 2001 From: duvbell Date: Tue, 24 Dec 2024 04:25:52 +0700 Subject: [PATCH 35/41] perf: decode proposal id from tx resp (#7785) * perf: decode proposal id from tx resp * Empty commit * perf: add defer function back * bet --------- Co-authored-by: Gjermund Garaba --- e2e/testsuite/tx.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/testsuite/tx.go b/e2e/testsuite/tx.go index 3fe40e1212d..c037ebb3d3b 100644 --- a/e2e/testsuite/tx.go +++ b/e2e/testsuite/tx.go @@ -222,16 +222,16 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Beta1Proposal(ctx context.Context, cha panic("ExecuteAndPassGovV1Beta1Proposal must be passed a cosmos.CosmosChain") } - proposalID := s.proposalIDs[chain.Config().ChainID] - defer func() { - s.proposalIDs[chain.Config().ChainID] = proposalID + 1 - }() - txResp := s.ExecuteGovV1Beta1Proposal(ctx, cosmosChain, user, content) s.AssertTxSuccess(txResp) - // TODO: replace with parsed proposal ID from MsgSubmitProposalResponse - // https://github.com/cosmos/ibc-go/issues/2122 + var submitProposalResponse govtypesv1beta1.MsgSubmitProposalResponse + s.Require().NoError(UnmarshalMsgResponses(txResp, &submitProposalResponse)) + + proposalID := submitProposalResponse.ProposalId + defer func() { + s.proposalIDs[chain.Config().ChainID] = proposalID + 1 + }() proposalResp, err := query.GRPCQuery[govtypesv1beta1.QueryProposalResponse](ctx, cosmosChain, &govtypesv1beta1.QueryProposalRequest{ ProposalId: proposalID, From f29db43d0ad36a370aa7c4041a512f3704c56142 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 21:35:06 +0000 Subject: [PATCH 36/41] chore(deps): bump google.golang.org/protobuf from 1.36.0 to 1.36.1 (#7791) * chore(deps): bump google.golang.org/protobuf from 1.36.0 to 1.36.1 Bumps google.golang.org/protobuf from 1.36.0 to 1.36.1. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: tidy all --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gjermund Garaba --- e2e/go.mod | 2 +- e2e/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- modules/apps/callbacks/go.mod | 2 +- modules/apps/callbacks/go.sum | 4 ++-- modules/light-clients/08-wasm/go.mod | 2 +- modules/light-clients/08-wasm/go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index d0528efd818..d09fb01335c 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -197,7 +197,7 @@ require ( google.golang.org/genproto v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect - google.golang.org/protobuf v1.36.0 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index d9a2920d1fb..4ea206035ef 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -1511,8 +1511,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/go.mod b/go.mod index 5406b125485..69a8c48dce8 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/stretchr/testify v1.10.0 google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 google.golang.org/grpc v1.69.2 - google.golang.org/protobuf v1.36.0 + google.golang.org/protobuf v1.36.1 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 957f3dc8c81..2ae31280674 100644 --- a/go.sum +++ b/go.sum @@ -1445,8 +1445,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index a0abce18ca1..c5fab44d530 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -219,7 +219,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect google.golang.org/grpc v1.69.2 // indirect - google.golang.org/protobuf v1.36.0 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 742ddc78936..e5697466f59 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -1441,8 +1441,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 822eef86d1a..4a77559c96a 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -227,7 +227,7 @@ require ( google.golang.org/api v0.192.0 // indirect google.golang.org/genproto v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect - google.golang.org/protobuf v1.36.0 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 09d1033b1dc..c65a1f660c1 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -1465,8 +1465,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/simapp/go.mod b/simapp/go.mod index 444d5c74042..4c47d17a3b6 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -227,7 +227,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect google.golang.org/grpc v1.69.2 // indirect - google.golang.org/protobuf v1.36.0 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 88881b083e3..7f614750419 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -1461,8 +1461,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 7d86244df1d672a807fbdf618183688a093796bb Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Fri, 27 Dec 2024 03:53:41 +0900 Subject: [PATCH 37/41] doc: fix invalid link 03-client-state.md (#7794) * fix invalid link 03-client-state.md "abci.go"'s link is invalid. "https://github.com/cosmos/ibc-go/blob/09-localhost/modules/core/02-client/abci.go#L12" -> "https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/abci.go#L12" * fix invalid link 03-client-state.md "https://github.com/cosmos/ibc-go/blob/09-localhost/modules/core/02-client/abci.go#L12" -> "https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/abci.go#L28" * fix invalid link 03-client-state.md "https://github.com/cosmos/ibc-go/blob/09-localhost/modules/core/02-client/abci.go#L12" -> "https://github.com/cosmos/ibc-go/blob/v8.5.0/modules/core/02-client/abci.go#L12" --- .../03-light-clients/02-localhost/03-client-state.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versioned_docs/version-v8.5.x/03-light-clients/02-localhost/03-client-state.md b/docs/versioned_docs/version-v8.5.x/03-light-clients/02-localhost/03-client-state.md index 19e03b62aa9..bb2cbe2e248 100644 --- a/docs/versioned_docs/version-v8.5.x/03-light-clients/02-localhost/03-client-state.md +++ b/docs/versioned_docs/version-v8.5.x/03-light-clients/02-localhost/03-client-state.md @@ -33,7 +33,7 @@ It is possible to disable the localhost client by removing the `09-localhost` en The latest height is updated periodically through the ABCI [`BeginBlock`](https://docs.cosmos.network/v0.47/building-modules/beginblock-endblock) interface of the 02-client submodule in core IBC. -[See `BeginBlocker` in abci.go.](https://github.com/cosmos/ibc-go/blob/09-localhost/modules/core/02-client/abci.go#L12) +[See `BeginBlocker` in abci.go.](https://github.com/cosmos/ibc-go/blob/v8.5.0/modules/core/02-client/abci.go#L12) ```go func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { From af8b6afc4ed8145fa25e93fbdc5d779e14e1960d Mon Sep 17 00:00:00 2001 From: Dmytrol <46675332+Dimitrolito@users.noreply.github.com> Date: Thu, 26 Dec 2024 22:07:29 +0200 Subject: [PATCH 38/41] Fix typographical errors (#7799) * typos 00-intro.md * typo events.go * typo keys.go * typo keys.go * typo keys.go * typo genesis.go * typo genesis.go * typo merkle.go --------- Co-authored-by: Gjermund Garaba --- .../version-v9.0.x/01-ibc/05-upgrades/00-intro.md | 2 +- modules/apps/transfer/keeper/events.go | 2 +- modules/core/02-client/types/keys.go | 2 +- modules/core/03-connection/types/keys.go | 2 +- modules/core/04-channel/types/keys.go | 2 +- modules/core/23-commitment/types/merkle.go | 2 +- simapp/genesis.go | 2 +- testing/simapp/genesis.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/versioned_docs/version-v9.0.x/01-ibc/05-upgrades/00-intro.md b/docs/versioned_docs/version-v9.0.x/01-ibc/05-upgrades/00-intro.md index 61711d35f01..d9b8ef25fae 100644 --- a/docs/versioned_docs/version-v9.0.x/01-ibc/05-upgrades/00-intro.md +++ b/docs/versioned_docs/version-v9.0.x/01-ibc/05-upgrades/00-intro.md @@ -9,7 +9,7 @@ slug: /ibc/upgrades/intro This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. -IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform a IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. +IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. 1. The [quick-guide](./01-quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the SDK. 2. The [developer-guide](./02-developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. diff --git a/modules/apps/transfer/keeper/events.go b/modules/apps/transfer/keeper/events.go index b797fcf1029..c30fdaabd9f 100644 --- a/modules/apps/transfer/keeper/events.go +++ b/modules/apps/transfer/keeper/events.go @@ -13,7 +13,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) -// EmitTransferEvent emits a ibc transfer event on successful transfers. +// EmitTransferEvent emits an ibc transfer event on successful transfers. func (k Keeper) EmitTransferEvent(ctx context.Context, sender, receiver string, tokens types.Tokens, memo string, forwardingHops []types.Hop) error { tokensStr := mustMarshalJSON(tokens) forwardingHopsStr := mustMarshalJSON(forwardingHops) diff --git a/modules/core/02-client/types/keys.go b/modules/core/02-client/types/keys.go index e0c23c96aaa..76ce77f08c7 100644 --- a/modules/core/02-client/types/keys.go +++ b/modules/core/02-client/types/keys.go @@ -35,7 +35,7 @@ const ( ) // FormatClientIdentifier returns the client identifier with the sequence appended. -// This is a SDK specific format not enforced by IBC protocol. +// This is an SDK specific format not enforced by IBC protocol. func FormatClientIdentifier(clientType string, sequence uint64) string { return fmt.Sprintf("%s-%d", clientType, sequence) } diff --git a/modules/core/03-connection/types/keys.go b/modules/core/03-connection/types/keys.go index ebea9087eb7..0eb2c756447 100644 --- a/modules/core/03-connection/types/keys.go +++ b/modules/core/03-connection/types/keys.go @@ -34,7 +34,7 @@ const ( ) // FormatConnectionIdentifier returns the connection identifier with the sequence appended. -// This is a SDK specific format not enforced by IBC protocol. +// This is an SDK specific format not enforced by IBC protocol. func FormatConnectionIdentifier(sequence uint64) string { return fmt.Sprintf("%s%d", ConnectionPrefix, sequence) } diff --git a/modules/core/04-channel/types/keys.go b/modules/core/04-channel/types/keys.go index 912582f0c8d..701c452d6d6 100644 --- a/modules/core/04-channel/types/keys.go +++ b/modules/core/04-channel/types/keys.go @@ -34,7 +34,7 @@ const ( ) // FormatChannelIdentifier returns the channel identifier with the sequence appended. -// This is a SDK specific format not enforced by IBC protocol. +// This is an SDK specific format not enforced by IBC protocol. func FormatChannelIdentifier(sequence uint64) string { return fmt.Sprintf("%s%d", ChannelPrefix, sequence) } diff --git a/modules/core/23-commitment/types/merkle.go b/modules/core/23-commitment/types/merkle.go index 9b6e4b0d073..5cdf72dddbd 100644 --- a/modules/core/23-commitment/types/merkle.go +++ b/modules/core/23-commitment/types/merkle.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/exported" ) -// var representing the proofspecs for a SDK chain +// var representing the proofspecs for an SDK chain var sdkSpecs = []*ics23.ProofSpec{ics23.IavlSpec, ics23.TendermintSpec} // ICS 023 Merkle Types Implementation diff --git a/simapp/genesis.go b/simapp/genesis.go index 69fa46b90ef..19328b3f2e0 100644 --- a/simapp/genesis.go +++ b/simapp/genesis.go @@ -5,7 +5,7 @@ import ( ) // GenesisState of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. +// messages key'd by an identifier string. // The identifier is used to determine which module genesis information belongs // to so it may be appropriately routed during init chain. // Within this application default genesis information is retrieved from diff --git a/testing/simapp/genesis.go b/testing/simapp/genesis.go index 69fa46b90ef..19328b3f2e0 100644 --- a/testing/simapp/genesis.go +++ b/testing/simapp/genesis.go @@ -5,7 +5,7 @@ import ( ) // GenesisState of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. +// messages key'd by an identifier string. // The identifier is used to determine which module genesis information belongs // to so it may be appropriately routed during init chain. // Within this application default genesis information is retrieved from From 89dc3550d94d0539d48d4f71c809cf322d9827ee Mon Sep 17 00:00:00 2001 From: futreall <86553580+futreall@users.noreply.github.com> Date: Tue, 31 Dec 2024 01:55:33 +0200 Subject: [PATCH 39/41] Update bug-report.md (#7803) --- .github/ISSUE_TEMPLATE/bug-report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 8b6a60b1fa2..39fcb0978e4 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -12,7 +12,7 @@ v Please also ensure that this is not a duplicate issue :) @@ -39,4 +39,4 @@ ____ - [ ] Not duplicate issue - [ ] Appropriate labels applied - [ ] Appropriate contributors tagged/assigned -- [ ] Estimate provided \ No newline at end of file +- [ ] Estimate provided From 0fb1e135a43597a069a88282c0c11ebd4aeb9e15 Mon Sep 17 00:00:00 2001 From: oliveredget <188809800+oliveredget@users.noreply.github.com> Date: Tue, 31 Dec 2024 08:09:03 +0800 Subject: [PATCH 40/41] docs: fix typographical errors (#7806) Signed-off-by: oliveredget <188809800+oliveredget@users.noreply.github.com> --- .../version-v4.6.x/01-ibc/05-upgrades/00-intro.md | 2 +- .../version-v5.4.x/01-ibc/05-upgrades/00-intro.md | 2 +- .../version-v6.3.x/01-ibc/05-upgrades/00-intro.md | 2 +- .../version-v7.8.x/01-ibc/05-upgrades/00-intro.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/versioned_docs/version-v4.6.x/01-ibc/05-upgrades/00-intro.md b/docs/versioned_docs/version-v4.6.x/01-ibc/05-upgrades/00-intro.md index 8d2b85c6f30..6c2b6915dd1 100644 --- a/docs/versioned_docs/version-v4.6.x/01-ibc/05-upgrades/00-intro.md +++ b/docs/versioned_docs/version-v4.6.x/01-ibc/05-upgrades/00-intro.md @@ -9,7 +9,7 @@ slug: /ibc/upgrades/intro This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. -IBC-connnected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. +IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. 1. The [quick-guide](./01-quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the SDK. 2. The [developer-guide](./02-developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. diff --git a/docs/versioned_docs/version-v5.4.x/01-ibc/05-upgrades/00-intro.md b/docs/versioned_docs/version-v5.4.x/01-ibc/05-upgrades/00-intro.md index 4fd3f740ca7..e484f29e71d 100644 --- a/docs/versioned_docs/version-v5.4.x/01-ibc/05-upgrades/00-intro.md +++ b/docs/versioned_docs/version-v5.4.x/01-ibc/05-upgrades/00-intro.md @@ -2,7 +2,7 @@ This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. -IBC-connnected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. +IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. 1. The [quick-guide](./01-quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the SDK. 2. The [developer-guide](./02-developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. diff --git a/docs/versioned_docs/version-v6.3.x/01-ibc/05-upgrades/00-intro.md b/docs/versioned_docs/version-v6.3.x/01-ibc/05-upgrades/00-intro.md index 8d2b85c6f30..6c2b6915dd1 100644 --- a/docs/versioned_docs/version-v6.3.x/01-ibc/05-upgrades/00-intro.md +++ b/docs/versioned_docs/version-v6.3.x/01-ibc/05-upgrades/00-intro.md @@ -9,7 +9,7 @@ slug: /ibc/upgrades/intro This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. -IBC-connnected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. +IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. 1. The [quick-guide](./01-quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the SDK. 2. The [developer-guide](./02-developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. diff --git a/docs/versioned_docs/version-v7.8.x/01-ibc/05-upgrades/00-intro.md b/docs/versioned_docs/version-v7.8.x/01-ibc/05-upgrades/00-intro.md index 3b979ea9c9f..5b1d04c009b 100644 --- a/docs/versioned_docs/version-v7.8.x/01-ibc/05-upgrades/00-intro.md +++ b/docs/versioned_docs/version-v7.8.x/01-ibc/05-upgrades/00-intro.md @@ -9,7 +9,7 @@ slug: /ibc/upgrades/intro This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. -IBC-connnected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. +IBC-connected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform an IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. 1. The [quick-guide](./01-quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the SDK. 2. The [developer-guide](./02-developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. From fc63b5c2274e13695d0273dfd27bb222ff971917 Mon Sep 17 00:00:00 2001 From: Gjermund Garaba Date: Tue, 31 Dec 2024 12:49:22 +0100 Subject: [PATCH 41/41] chore: add hidden folders to codespell + fail on pr (#7808) * chore: add hidden folders to codespell * add .github to codespell * fail code spell checker on PRs * fix spelling error in e2e gh action --- .github/workflows/e2e.yaml | 2 +- .github/workflows/spell-checker.yml | 4 ++-- modules/core/04-channel/keeper/upgrade_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 731a142df95..67414eb1ef5 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -65,6 +65,6 @@ jobs: chain-a-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' # on regular PRs we won't run upgrade tests. - # NOTE: we are exluding TestTransferTestSuite as we run this full suite instead of each individual test. + # NOTE: we are excluding TestTransferTestSuite as we run this full suite instead of each individual test. test-exclusions: 'TestUpgradeTestSuite,TestIBCWasmUpgradeTestSuite,TestTransferTestSuite,TestAuthzTransferTestSuite,TestTransferTestSuiteSendReceive,TestTransferTestSuiteSendEnabled,TestTransferLocalhostTestSuite,TestConnectionTestSuite,TestInterchainAccountsGovTestSuite,TestIncentivizedTransferTestSuite,TestTransferForwardingTestSuite' temp-run-full-suite: true diff --git a/.github/workflows/spell-checker.yml b/.github/workflows/spell-checker.yml index e2399eaa619..746bdbbd2de 100644 --- a/.github/workflows/spell-checker.yml +++ b/.github/workflows/spell-checker.yml @@ -22,8 +22,8 @@ jobs: - name: Install codespell run: pip install codespell - name: Run codespell - continue-on-error: true - run: codespell -w --skip="*.pb.go,*.pb.gw.go,*.json,*.git,*.js,*.h,*.bin,go.sum,go.mod,.github,*.pdf,*.tla" --ignore-words=.github/.codespellignore + continue-on-error: ${{ github.event_name != 'pull_request' }} + run: codespell -w --skip="*.pb.go,*.pb.gw.go,*.json,*.git,*.js,*.h,*.bin,go.sum,go.mod,*.pdf,*.tla" --ignore-words=.github/.codespellignore --check-hidden - uses: peter-evans/create-pull-request@v7 if: github.event_name != 'pull_request' with: diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 26ee0e22b6d..f1c49dbeebb 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -2492,8 +2492,8 @@ func (suite *KeeperTestSuite) TestAbortUpgrade() { errorReceipt, found := channelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) suite.Require().True(found, "error receipt should be found") - if ue, ok := upgradeError.(*types.UpgradeError); ok { - suite.Require().Equal(ue.GetErrorReceipt(), errorReceipt, "error receipt does not match expected error receipt") + if upgradeError, ok := upgradeError.(*types.UpgradeError); ok { + suite.Require().Equal(upgradeError.GetErrorReceipt(), errorReceipt, "error receipt does not match expected error receipt") } } else {