From f36e605cddf54c88eada84fb5db0c63650fac1e8 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 10 Dec 2024 14:35:27 +0200 Subject: [PATCH 01/25] wasmd path --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 550853bd4..fb58cab9d 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/x/tx v0.13.5 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.53.0 - github.com/CosmWasm/wasmvm/v2 v2.1.3 + github.com/CosmWasm/wasmvm/v2 v2.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2 github.com/cosmos/cosmos-db v1.0.2 @@ -219,7 +219,7 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.0-neutron + github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.2 github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.10-neutron diff --git a/go.sum b/go.sum index c38fdc06a..455d91335 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,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.3 h1:CSJTauZqkHyb9yic6JVYCjiGUgxI2MJV2QzfSu8m49c= -github.com/CosmWasm/wasmvm/v2 v2.1.3/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 h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= @@ -830,8 +830,8 @@ github.com/neutron-org/admin-module/v2 v2.0.2 h1:XDDFWjvkVBKRf3lBFCazT1zAXZ3dHX8 github.com/neutron-org/admin-module/v2 v2.0.2/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA= github.com/neutron-org/cosmos-sdk v0.50.10-neutron h1:1q8P0l29Mm22m8wUstKlCZpKScJOa5bFFqkO/RbHL5w= github.com/neutron-org/cosmos-sdk v0.50.10-neutron/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= -github.com/neutron-org/wasmd v0.53.0-neutron h1:Dv1VP1+QjYeb6RMo03sxw0Pe42JU0MPxefwNaG22KVs= -github.com/neutron-org/wasmd v0.53.0-neutron/go.mod h1:FJl/aWjdpGof3usAMFQpDe07Rkx77PUzp0cygFMOvtw= +github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d h1:ZyVr+jk+4ShGHKP19pTQvhoI8b26xruG3ghg3IUP7j4= +github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= From 483b563aa33ae2e39ce8e16e2e44ab11cd090ee1 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 10 Dec 2024 22:03:49 +0200 Subject: [PATCH 02/25] wasmd patch --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fb58cab9d..2cfffe20a 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/tx v0.13.5 cosmossdk.io/x/upgrade v0.1.4 - github.com/CosmWasm/wasmd v0.53.0 + github.com/CosmWasm/wasmd v0.53.2 github.com/CosmWasm/wasmvm/v2 v2.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2 @@ -219,7 +219,7 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d + github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.2 github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.10-neutron diff --git a/go.sum b/go.sum index 455d91335..e879e5fec 100644 --- a/go.sum +++ b/go.sum @@ -830,8 +830,8 @@ github.com/neutron-org/admin-module/v2 v2.0.2 h1:XDDFWjvkVBKRf3lBFCazT1zAXZ3dHX8 github.com/neutron-org/admin-module/v2 v2.0.2/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA= github.com/neutron-org/cosmos-sdk v0.50.10-neutron h1:1q8P0l29Mm22m8wUstKlCZpKScJOa5bFFqkO/RbHL5w= github.com/neutron-org/cosmos-sdk v0.50.10-neutron/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= -github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d h1:ZyVr+jk+4ShGHKP19pTQvhoI8b26xruG3ghg3IUP7j4= -github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210112813-b7ce9cf4f33d/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= +github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b h1:ZtG4fvAlsYY38fSwCgLhzoyH94Jx4UrKL+4r92O0Rds= +github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= From 8507a8e08a52af847e327402dd0605ffecfdf0cb Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Wed, 11 Dec 2024 16:39:54 +0200 Subject: [PATCH 03/25] wasmd patch --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2cfffe20a..c5af02c8b 100644 --- a/go.mod +++ b/go.mod @@ -219,7 +219,7 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b + github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.2-neutron github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.2 github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.10-neutron diff --git a/go.sum b/go.sum index e879e5fec..baeb3f200 100644 --- a/go.sum +++ b/go.sum @@ -830,8 +830,8 @@ github.com/neutron-org/admin-module/v2 v2.0.2 h1:XDDFWjvkVBKRf3lBFCazT1zAXZ3dHX8 github.com/neutron-org/admin-module/v2 v2.0.2/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA= github.com/neutron-org/cosmos-sdk v0.50.10-neutron h1:1q8P0l29Mm22m8wUstKlCZpKScJOa5bFFqkO/RbHL5w= github.com/neutron-org/cosmos-sdk v0.50.10-neutron/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= -github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b h1:ZtG4fvAlsYY38fSwCgLhzoyH94Jx4UrKL+4r92O0Rds= -github.com/neutron-org/wasmd v0.53.0-neutron.0.20241210195637-d8d8c8914a8b/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= +github.com/neutron-org/wasmd v0.53.2-neutron h1:+2QThKYBTbB1oYwkb+rzxfaMBuB+ZGySlS+7fmFEWIs= +github.com/neutron-org/wasmd v0.53.2-neutron/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= From 921dc825c1d6c038dfff739253a89753e6e23a60 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Mon, 16 Dec 2024 16:40:18 +0200 Subject: [PATCH 04/25] fix build --- go.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.sum b/go.sum index f3dc703ef..12af17242 100644 --- a/go.sum +++ b/go.sum @@ -978,7 +978,7 @@ github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610 h1:4JlsiRVt github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610/go.mod h1:kB8gFZX07CyJnw8q9iEZijI3qJTIe1K/Y++P5VGkrcg= github.com/skip-mev/feemarket v1.1.1 h1:L34K7N2J6o635kzNYRAvQ93+hAFtSiJ2t03jmaNx0zw= github.com/skip-mev/feemarket v1.1.1/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc= -github.com/skip-mev/slinky v1.0.13 h1:Ym+xqrhq1kJzyyJICGc2gB43+EETGy72sumZUU1wCt8= +github.com/skip-mev/slinky v1.0.13 h1:EIdcrUrrPt9UgCUZTupM28XoMPHNsLvMDHRD0oKe/Ck= github.com/skip-mev/slinky v1.0.13/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= From d41da4418eb18481950434450d3ee0141f5d0d3e Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Mon, 16 Dec 2024 16:59:43 +0200 Subject: [PATCH 05/25] fix build --- go.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.sum b/go.sum index baeb3f200..8e5bf1983 100644 --- a/go.sum +++ b/go.sum @@ -966,7 +966,7 @@ github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610 h1:4JlsiRVt github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610/go.mod h1:kB8gFZX07CyJnw8q9iEZijI3qJTIe1K/Y++P5VGkrcg= github.com/skip-mev/feemarket v1.1.1 h1:L34K7N2J6o635kzNYRAvQ93+hAFtSiJ2t03jmaNx0zw= github.com/skip-mev/feemarket v1.1.1/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc= -github.com/skip-mev/slinky v1.0.13 h1:Ym+xqrhq1kJzyyJICGc2gB43+EETGy72sumZUU1wCt8= +github.com/skip-mev/slinky v1.0.13 h1:EIdcrUrrPt9UgCUZTupM28XoMPHNsLvMDHRD0oKe/Ck= github.com/skip-mev/slinky v1.0.13/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= From 5e5b1c94014985571997dc2a33d67a72688153e8 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 17 Dec 2024 12:27:56 +0200 Subject: [PATCH 06/25] bump sdk --- go.mod | 16 ++++++++-------- go.sum | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index c5af02c8b..d44cd951a 100644 --- a/go.mod +++ b/go.mod @@ -13,15 +13,15 @@ require ( cosmossdk.io/store v1.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.7 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmd v0.53.2 github.com/CosmWasm/wasmvm/v2 v2.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2 - github.com/cosmos/cosmos-db v1.0.2 + github.com/cosmos/cosmos-db v1.1.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.50.10 + github.com/cosmos/cosmos-sdk v0.50.11 github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 github.com/cosmos/ibc-go/modules/capability v1.0.1 @@ -60,9 +60,9 @@ require ( cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.1.9 // indirect cloud.google.com/go/storage v1.41.0 // indirect - cosmossdk.io/api v0.7.5 // indirect + cosmossdk.io/api v0.7.6 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/depinject v1.0.0 // indirect + cosmossdk.io/depinject v1.1.0 // indirect cosmossdk.io/x/circuit v0.1.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -81,14 +81,14 @@ require ( github.com/cockroachdb/errors v1.11.3 // indirect github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.14.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.2 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -222,7 +222,7 @@ replace ( github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.2-neutron github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.2 - github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.10-neutron + github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555 // explicitely replace iavl to v1.2.0 cause sometimes go mod tidy uses not right version github.com/cosmos/iavl => github.com/cosmos/iavl v1.2.0 github.com/cosmos/interchain-security/v5 => github.com/cosmos/interchain-security/v5 v5.0.0-20240802125602-fa1e09444aae diff --git a/go.sum b/go.sum index 8e5bf1983..0c771d466 100644 --- a/go.sum +++ b/go.sum @@ -186,16 +186,16 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= -cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY= +cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= cosmossdk.io/client/v2 v2.0.0-beta.4 h1:LGIzWbVTOof/IHQZeoWwxPX0fq607ONXhsfA7eUrQIg= cosmossdk.io/client/v2 v2.0.0-beta.4/go.mod h1:c753d0sBv3AQRx6X+BOKL1aGpKjZMTZAHGiLPbVi5TE= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA= cosmossdk.io/core v0.11.1/go.mod h1:OJzxcdC+RPrgGF8NJZR2uoQr56tc7gfBKhiKeDO7hH0= -cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= -cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= +cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E= +cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= @@ -212,8 +212,8 @@ cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= cosmossdk.io/x/nft v0.1.1 h1:pslAVS8P5NkW080+LWOamInjDcq+v2GSCo+BjN9sxZ8= cosmossdk.io/x/nft v0.1.1/go.mod h1:Kac6F6y2gsKvoxU+fy8uvxRTi4BIhLOor2zgCNQwVgY= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.7 h1:8WSk6B/OHJLYjiZeMKhq7DK7lHDMyK0UfDbBMxVmeOI= +cosmossdk.io/x/tx v0.13.7/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -326,8 +326,8 @@ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/e github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -345,8 +345,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 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.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= -github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= +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-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/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= @@ -828,8 +828,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neutron-org/admin-module/v2 v2.0.2 h1:XDDFWjvkVBKRf3lBFCazT1zAXZ3dHX8GaZ4ol8Hdk8I= github.com/neutron-org/admin-module/v2 v2.0.2/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA= -github.com/neutron-org/cosmos-sdk v0.50.10-neutron h1:1q8P0l29Mm22m8wUstKlCZpKScJOa5bFFqkO/RbHL5w= -github.com/neutron-org/cosmos-sdk v0.50.10-neutron/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= +github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555 h1:vaYm5YryqGVdNFMjE/ZeFJp1KhMs4s3JAGWOjXyTiSA= +github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555/go.mod h1:gt14Meok2IDCjbDtjwkbUcgVNEpUBDN/4hg9cCUtLgw= github.com/neutron-org/wasmd v0.53.2-neutron h1:+2QThKYBTbB1oYwkb+rzxfaMBuB+ZGySlS+7fmFEWIs= github.com/neutron-org/wasmd v0.53.2-neutron/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= From 21ad6cb578aec98261a5c13b9ae960bedc544ad2 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 17 Dec 2024 17:55:36 +0200 Subject: [PATCH 07/25] fix slinky version because v1.0.13 release is broken --- go.mod | 2 +- go.sum | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d44cd951a..549f8f6b2 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/rs/zerolog v1.33.0 github.com/skip-mev/block-sdk/v2 v2.1.5 github.com/skip-mev/feemarket v1.1.1 - github.com/skip-mev/slinky v1.0.13 + github.com/skip-mev/slinky v1.0.13-0.20241114205023-22fefb0864ba github.com/spf13/cast v1.7.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 0c771d466..9ca6b4b95 100644 --- a/go.sum +++ b/go.sum @@ -966,7 +966,10 @@ github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610 h1:4JlsiRVt github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610/go.mod h1:kB8gFZX07CyJnw8q9iEZijI3qJTIe1K/Y++P5VGkrcg= github.com/skip-mev/feemarket v1.1.1 h1:L34K7N2J6o635kzNYRAvQ93+hAFtSiJ2t03jmaNx0zw= github.com/skip-mev/feemarket v1.1.1/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc= -github.com/skip-mev/slinky v1.0.13 h1:EIdcrUrrPt9UgCUZTupM28XoMPHNsLvMDHRD0oKe/Ck= +github.com/skip-mev/slinky v1.0.12 h1:qmZHB6c5fgDhO/pv67YcZc2M25t3gZcceVmJtA9zjOo= +github.com/skip-mev/slinky v1.0.12/go.mod h1:8mxMdQ8MY8QAxgxLvUKTfDwX6XCAUeqZwkU/r+ZsELU= +github.com/skip-mev/slinky v1.0.13-0.20241114205023-22fefb0864ba h1:W16sNjlHEcnE5Vrgw934+wWxf/FoznSY6xbS6R9QQ7A= +github.com/skip-mev/slinky v1.0.13-0.20241114205023-22fefb0864ba/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= github.com/skip-mev/slinky v1.0.13/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= From d29c0b2a93c37c0a8fd7c3856403404a42d26ede Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 17 Dec 2024 17:56:36 +0200 Subject: [PATCH 08/25] proper cosmos-sdk version --- go.mod | 2 +- go.sum | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 549f8f6b2..2306bf726 100644 --- a/go.mod +++ b/go.mod @@ -222,7 +222,7 @@ replace ( github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.53.2-neutron github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.2 - github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555 + github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.11-neutron // explicitely replace iavl to v1.2.0 cause sometimes go mod tidy uses not right version github.com/cosmos/iavl => github.com/cosmos/iavl v1.2.0 github.com/cosmos/interchain-security/v5 => github.com/cosmos/interchain-security/v5 v5.0.0-20240802125602-fa1e09444aae diff --git a/go.sum b/go.sum index 9ca6b4b95..4105f4a18 100644 --- a/go.sum +++ b/go.sum @@ -828,8 +828,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neutron-org/admin-module/v2 v2.0.2 h1:XDDFWjvkVBKRf3lBFCazT1zAXZ3dHX8GaZ4ol8Hdk8I= github.com/neutron-org/admin-module/v2 v2.0.2/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA= -github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555 h1:vaYm5YryqGVdNFMjE/ZeFJp1KhMs4s3JAGWOjXyTiSA= -github.com/neutron-org/cosmos-sdk v0.50.8-neutron.0.20241217101720-d808b381e555/go.mod h1:gt14Meok2IDCjbDtjwkbUcgVNEpUBDN/4hg9cCUtLgw= +github.com/neutron-org/cosmos-sdk v0.50.11-neutron h1:7XfK0XD+iDAq0LlAeZqG52oVipeYKFRgIldhYg0TmcU= +github.com/neutron-org/cosmos-sdk v0.50.11-neutron/go.mod h1:gt14Meok2IDCjbDtjwkbUcgVNEpUBDN/4hg9cCUtLgw= github.com/neutron-org/wasmd v0.53.2-neutron h1:+2QThKYBTbB1oYwkb+rzxfaMBuB+ZGySlS+7fmFEWIs= github.com/neutron-org/wasmd v0.53.2-neutron/go.mod h1:gP10E56tuToU5rsZR7vZLBL5ssW2mie6KN/WrQLG7/I= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -966,11 +966,8 @@ github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610 h1:4JlsiRVt github.com/skip-mev/chaintestutil v0.0.0-20240514161515-056d7ba45610/go.mod h1:kB8gFZX07CyJnw8q9iEZijI3qJTIe1K/Y++P5VGkrcg= github.com/skip-mev/feemarket v1.1.1 h1:L34K7N2J6o635kzNYRAvQ93+hAFtSiJ2t03jmaNx0zw= github.com/skip-mev/feemarket v1.1.1/go.mod h1:DUa6djUsTeMOrbrcIZqWSVxU9IZNCXp96ruaojyBNpc= -github.com/skip-mev/slinky v1.0.12 h1:qmZHB6c5fgDhO/pv67YcZc2M25t3gZcceVmJtA9zjOo= -github.com/skip-mev/slinky v1.0.12/go.mod h1:8mxMdQ8MY8QAxgxLvUKTfDwX6XCAUeqZwkU/r+ZsELU= github.com/skip-mev/slinky v1.0.13-0.20241114205023-22fefb0864ba h1:W16sNjlHEcnE5Vrgw934+wWxf/FoznSY6xbS6R9QQ7A= github.com/skip-mev/slinky v1.0.13-0.20241114205023-22fefb0864ba/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= -github.com/skip-mev/slinky v1.0.13/go.mod h1:OgOJivOCJQqjGefvoe/kzszCJKgK/hrXluoPiGJHTwU= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= From 981f77c439f9b7c90f84188aa48e83e71dbf6ad6 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Tue, 17 Dec 2024 18:46:33 +0200 Subject: [PATCH 09/25] v5.0.4 upgrade handler --- app/app.go | 2 ++ app/upgrades/v5.0.4/constants.go | 18 ++++++++++++++ app/upgrades/v5.0.4/upgrades.go | 35 ++++++++++++++++++++++++++ app/upgrades/v5.0.4/upgrades_test.go | 37 ++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 app/upgrades/v5.0.4/constants.go create mode 100644 app/upgrades/v5.0.4/upgrades.go create mode 100644 app/upgrades/v5.0.4/upgrades_test.go diff --git a/app/app.go b/app/app.go index e07388ec8..8f9d2d0ce 100644 --- a/app/app.go +++ b/app/app.go @@ -11,6 +11,7 @@ import ( "time" v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2" + v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types" "github.com/skip-mev/feemarket/x/feemarket" @@ -230,6 +231,7 @@ var ( Upgrades = []upgrades.Upgrade{ v500.Upgrade, v502.Upgrade, + v504.Upgrade, } // DefaultNodeHome default home directories for the application daemon diff --git a/app/upgrades/v5.0.4/constants.go b/app/upgrades/v5.0.4/constants.go new file mode 100644 index 000000000..1035a1d97 --- /dev/null +++ b/app/upgrades/v5.0.4/constants.go @@ -0,0 +1,18 @@ +package v504 + +import ( + storetypes "cosmossdk.io/store/types" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v5.0.4" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{}, +} diff --git a/app/upgrades/v5.0.4/upgrades.go b/app/upgrades/v5.0.4/upgrades.go new file mode 100644 index 000000000..a653fd29a --- /dev/null +++ b/app/upgrades/v5.0.4/upgrades.go @@ -0,0 +1,35 @@ +package v504 + +import ( + "context" + "fmt" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ *upgrades.UpgradeKeepers, + _ upgrades.StoreKeys, + _ codec.Codec, +) upgradetypes.UpgradeHandler { + return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(c) + + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) + return vm, nil + } +} diff --git a/app/upgrades/v5.0.4/upgrades_test.go b/app/upgrades/v5.0.4/upgrades_test.go new file mode 100644 index 000000000..b3810f025 --- /dev/null +++ b/app/upgrades/v5.0.4/upgrades_test.go @@ -0,0 +1,37 @@ +package v504_test + +import ( + "testing" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" + "github.com/neutron-org/neutron/v5/testutil" +) + +type UpgradeTestSuite struct { + testutil.IBCConnectionTestSuite +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (suite *UpgradeTestSuite) SetupTest() { + suite.IBCConnectionTestSuite.SetupTest() +} + +func (suite *UpgradeTestSuite) TestOracleUpgrade() { + app := suite.GetNeutronZoneApp(suite.ChainA) + ctx := suite.ChainA.GetContext().WithChainID("neutron-1") + t := suite.T() + + upgrade := upgradetypes.Plan{ + Name: v504.UpgradeName, + Info: "some text here", + Height: 100, + } + require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) +} From 2312066ee4c34f5d7ec789786e84e888ab353bfb Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Thu, 19 Dec 2024 12:26:32 +0000 Subject: [PATCH 10/25] chore: tests refactoring --- app/app.go | 1 + tests/ibc/tokenfactory_transfer_test.go | 90 +++++++++++++++++++++++++ x/tokenfactory/keeper/bankactions.go | 26 +++++++ x/tokenfactory/keeper/keeper.go | 16 +++++ 4 files changed, 133 insertions(+) create mode 100644 tests/ibc/tokenfactory_transfer_test.go diff --git a/app/app.go b/app/app.go index 8f9d2d0ce..30967e9f4 100644 --- a/app/app.go +++ b/app/app.go @@ -694,6 +694,7 @@ func New( &app.BankKeeper, &app.WasmKeeper, authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), + app.IBCKeeper.ChannelKeeper, ) app.TokenFactoryKeeper = &tokenFactoryKeeper diff --git a/tests/ibc/tokenfactory_transfer_test.go b/tests/ibc/tokenfactory_transfer_test.go new file mode 100644 index 000000000..610f92a4f --- /dev/null +++ b/tests/ibc/tokenfactory_transfer_test.go @@ -0,0 +1,90 @@ +package ibc_test + +import ( + "fmt" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + tftypes "github.com/neutron-org/neutron/v5/x/tokenfactory/types" + "github.com/stretchr/testify/suite" +) + +type TokenfactoryTestSuite struct { + IBCTestSuite +} + +func TestPocTestSuite(t *testing.T) { + suite.Run(t, new(TokenfactoryTestSuite)) +} + +func (s *TokenfactoryTestSuite) TestForceTransferFromIBCEscrow() { + // Create token factory denom + createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") + _, err := s.neutronChain.SendMsgs(createDenomMsg) + s.Assert().NoError(err) + + // Derive full token factory denom + denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) + + // Mint denom to sender + amount := sdk.NewCoin(denom, math.NewInt(10000000)) + mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) + _, err = s.neutronChain.SendMsgs(mintMsg) + s.Assert().NoError(err) + + // Send IBC transfer + s.IBCTransfer( + s.neutronTransferPath, + s.neutronTransferPath.EndpointA, + s.neutronAddr, + s.providerAddr, + amount.Denom, + amount.Amount, + "", + ) + + // Derive IBC escrow address for channel + escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) + + // Transfer tokens out of escrow address + forceTransferMsg := tftypes.NewMsgForceTransfer(s.neutronAddr.String(), sdk.NewCoin(amount.Denom, amount.Amount), escrowAddress.String(), s.neutronAddr.String()) + _, err = s.neutronChain.SendMsgs(forceTransferMsg) + s.Assert().Error(err) +} + +func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { + // Create token factory denom + createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") + _, err := s.neutronChain.SendMsgs(createDenomMsg) + s.Assert().NoError(err) + + // Derive full token factory denom + denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) + + // Mint denom to sender + amount := sdk.NewCoin(denom, math.NewInt(10000000)) + mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) + _, err = s.neutronChain.SendMsgs(mintMsg) + s.Assert().NoError(err) + + // Send IBC transfer + s.IBCTransfer( + s.neutronTransferPath, + s.neutronTransferPath.EndpointA, + s.neutronAddr, + s.providerAddr, + amount.Denom, + amount.Amount, + "", + ) + + // Derive IBC escrow address for channel + escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) + + // Burn tokens from escrow address + burnMsg := tftypes.NewMsgBurnFrom(s.neutronAddr.String(), amount, escrowAddress.String()) + _, err = s.neutronChain.SendMsgs(burnMsg) + s.Assert().Error(err) +} diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index ed2f7d565..5f883f63b 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -50,6 +50,12 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } + escrowAccounts := k.GetAllEscrowAccounts(ctx) + + if k.isEscrowAccount(escrowAccounts, burnFromAcc) { + return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") + } + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, burnFromAcc, types.ModuleName, @@ -86,6 +92,16 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } + escrowAccounts := k.GetAllEscrowAccounts(ctx) + + if k.isEscrowAccount(escrowAccounts, transferFromAcc) { + return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") + } + + if k.isEscrowAccount(escrowAccounts, transferToAcc) { + return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") + } + return k.bankKeeper.SendCoins(ctx, transferFromAcc, transferToAcc, sdk.NewCoins(amount)) } @@ -103,3 +119,13 @@ func (k Keeper) isModuleAccount(ctx sdk.Context, addr sdk.AccAddress) bool { return false } + +func (k Keeper) isEscrowAccount(escrowAccounts []sdk.AccAddress, addr sdk.AccAddress) bool { + for _, escrowAccount := range escrowAccounts { + if escrowAccount.Equals(addr) { + return true + } + } + + return false +} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 241183ca1..0fa517ad8 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -10,6 +10,8 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" "github.com/neutron-org/neutron/v5/x/tokenfactory/types" ) @@ -23,6 +25,7 @@ type ( bankKeeper types.BankKeeper contractKeeper types.ContractKeeper authority string + channelKeeper channelkeeper.Keeper } ) @@ -35,6 +38,7 @@ func NewKeeper( bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, authority string, + channelKeeper channelkeeper.Keeper, ) Keeper { sortedKnownModules := make([]string, 0, len(maccPerms)) for moduleName := range maccPerms { @@ -50,6 +54,7 @@ func NewKeeper( bankKeeper: bankKeeper, contractKeeper: contractKeeper, authority: authority, + channelKeeper: channelKeeper, } } @@ -96,3 +101,14 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { // GetModuleAccount creates new module account if not present under the hood k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) } + +func (k Keeper) GetAllEscrowAccounts(ctx sdk.Context) []sdk.AccAddress { + var escrowAddresses []sdk.AccAddress + + transferChannels := k.channelKeeper.GetAllChannels(ctx) + for _, channel := range transferChannels { + escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)) + } + + return escrowAddresses +} From 0935c098dde089f3e0be40f049368ecfc2dc96b5 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Thu, 19 Dec 2024 13:00:05 +0000 Subject: [PATCH 11/25] better assertions --- ...{tokenfactory_transfer_test.go => tokenfactory_test.go} | 4 ++-- x/tokenfactory/keeper/bankactions.go | 6 +++--- x/tokenfactory/keeper/keeper.go | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) rename tests/ibc/{tokenfactory_transfer_test.go => tokenfactory_test.go} (94%) diff --git a/tests/ibc/tokenfactory_transfer_test.go b/tests/ibc/tokenfactory_test.go similarity index 94% rename from tests/ibc/tokenfactory_transfer_test.go rename to tests/ibc/tokenfactory_test.go index 610f92a4f..0402bfef6 100644 --- a/tests/ibc/tokenfactory_transfer_test.go +++ b/tests/ibc/tokenfactory_test.go @@ -51,7 +51,7 @@ func (s *TokenfactoryTestSuite) TestForceTransferFromIBCEscrow() { // Transfer tokens out of escrow address forceTransferMsg := tftypes.NewMsgForceTransfer(s.neutronAddr.String(), sdk.NewCoin(amount.Denom, amount.Amount), escrowAddress.String(), s.neutronAddr.String()) _, err = s.neutronChain.SendMsgs(forceTransferMsg) - s.Assert().Error(err) + s.Assert().ErrorContains(err, "force transfer from IBC escrow accounts is forbidden") } func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { @@ -86,5 +86,5 @@ func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { // Burn tokens from escrow address burnMsg := tftypes.NewMsgBurnFrom(s.neutronAddr.String(), amount, escrowAddress.String()) _, err = s.neutronChain.SendMsgs(burnMsg) - s.Assert().Error(err) + s.Assert().ErrorContains(err, "burning from escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 5f883f63b..d355e323a 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -52,7 +52,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro escrowAccounts := k.GetAllEscrowAccounts(ctx) - if k.isEscrowAccount(escrowAccounts, burnFromAcc) { + if _, ok := escrowAccounts[burnFromAcc.String()]; ok { return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") } @@ -94,11 +94,11 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr escrowAccounts := k.GetAllEscrowAccounts(ctx) - if k.isEscrowAccount(escrowAccounts, transferFromAcc) { + if _, ok := escrowAccounts[transferFromAcc.String()]; ok { return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") } - if k.isEscrowAccount(escrowAccounts, transferToAcc) { + if _, ok := escrowAccounts[transferToAcc.String()]; ok { return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 0fa517ad8..3cdf299b8 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -102,12 +102,13 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) } -func (k Keeper) GetAllEscrowAccounts(ctx sdk.Context) []sdk.AccAddress { - var escrowAddresses []sdk.AccAddress +func (k Keeper) GetAllEscrowAccounts(ctx sdk.Context) map[string]bool { + escrowAddresses := make(map[string]bool) transferChannels := k.channelKeeper.GetAllChannels(ctx) for _, channel := range transferChannels { - escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)) + escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) + escrowAddresses[escrowAddress.String()] = true } return escrowAddresses From b4bb189cee9433958ae9b73fba1c30d9e1f9f016 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Thu, 19 Dec 2024 14:30:42 +0000 Subject: [PATCH 12/25] removed unused functions, renamed other functions --- x/tokenfactory/keeper/bankactions.go | 14 ++------------ x/tokenfactory/keeper/keeper.go | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index d355e323a..e0f4ae7de 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -50,7 +50,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } - escrowAccounts := k.GetAllEscrowAccounts(ctx) + escrowAccounts := k.GetAllIBCEscrowAccounts(ctx) if _, ok := escrowAccounts[burnFromAcc.String()]; ok { return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") @@ -92,7 +92,7 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } - escrowAccounts := k.GetAllEscrowAccounts(ctx) + escrowAccounts := k.GetAllIBCEscrowAccounts(ctx) if _, ok := escrowAccounts[transferFromAcc.String()]; ok { return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") @@ -119,13 +119,3 @@ func (k Keeper) isModuleAccount(ctx sdk.Context, addr sdk.AccAddress) bool { return false } - -func (k Keeper) isEscrowAccount(escrowAccounts []sdk.AccAddress, addr sdk.AccAddress) bool { - for _, escrowAccount := range escrowAccounts { - if escrowAccount.Equals(addr) { - return true - } - } - - return false -} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 3cdf299b8..841863498 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -102,7 +102,7 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) } -func (k Keeper) GetAllEscrowAccounts(ctx sdk.Context) map[string]bool { +func (k Keeper) GetAllIBCEscrowAccounts(ctx sdk.Context) map[string]bool { escrowAddresses := make(map[string]bool) transferChannels := k.channelKeeper.GetAllChannels(ctx) From ab22b9d0119046b91e8284e6fcbe0a5b1bb1229d Mon Sep 17 00:00:00 2001 From: Aleksandr Pismenskiy Date: Thu, 19 Dec 2024 18:07:09 +0300 Subject: [PATCH 13/25] fix msg_server tests --- testutil/tokenfactory/keeper/tokenfactory.go | 2 ++ x/tokenfactory/keeper/keeper.go | 5 ++--- x/tokenfactory/keeper/msg_server_test.go | 18 +++++++++--------- x/tokenfactory/types/expected_keepers.go | 6 ++++++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/testutil/tokenfactory/keeper/tokenfactory.go b/testutil/tokenfactory/keeper/tokenfactory.go index f65b1ab31..67bae4639 100644 --- a/testutil/tokenfactory/keeper/tokenfactory.go +++ b/testutil/tokenfactory/keeper/tokenfactory.go @@ -24,6 +24,7 @@ func TokenFactoryKeeper( accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, + channelKeeper types.ChannelKeeper, ) (keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -45,6 +46,7 @@ func TokenFactoryKeeper( bankKeeper, contractKeeper, testutil.TestOwnerAddress, + channelKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 841863498..23aa80c3c 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" "github.com/neutron-org/neutron/v5/x/tokenfactory/types" ) @@ -25,7 +24,7 @@ type ( bankKeeper types.BankKeeper contractKeeper types.ContractKeeper authority string - channelKeeper channelkeeper.Keeper + channelKeeper types.ChannelKeeper } ) @@ -38,7 +37,7 @@ func NewKeeper( bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, authority string, - channelKeeper channelkeeper.Keeper, + channelKeeper types.ChannelKeeper, ) Keeper { sortedKnownModules := make([]string, 0, len(maccPerms)) for moduleName := range maccPerms { diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 70bd4158d..e07ba0aa0 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -23,7 +23,7 @@ const ( ) func TestMsgCreateDenomValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -68,7 +68,7 @@ func TestMsgCreateDenomValidate(t *testing.T) { } func TestMsgMintValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -162,7 +162,7 @@ func TestMsgMintValidate(t *testing.T) { } func TestMsgBurnValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -256,7 +256,7 @@ func TestMsgBurnValidate(t *testing.T) { } func TestMsgForceTransferValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -375,7 +375,7 @@ func TestMsgForceTransferValidate(t *testing.T) { } func TestMsgChangeAdminValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -450,7 +450,7 @@ func TestMsgChangeAdminValidate(t *testing.T) { } func TestMsgSetDenomMetadataValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -781,7 +781,7 @@ func TestMsgSetDenomMetadataValidate(t *testing.T) { } func TestMsgSetBeforeSendHookValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -847,7 +847,7 @@ func TestMsgSetBeforeSendHookValidate(t *testing.T) { } func TestMsgUpdateParamsValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) tests := []struct { name string @@ -913,7 +913,7 @@ func TestMsgUpdateParamsValidate(t *testing.T) { } func TestMsgUpdateParamsWhitelistedHooks(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) tests := []struct { name string diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 45e7d8b0e..8b95d9189 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -6,6 +6,7 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) type BankKeeper interface { @@ -39,3 +40,8 @@ type ContractKeeper interface { Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *wasmtypes.ContractInfo } + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetAllChannels(ctx sdk.Context) (channels []channeltypes.IdentifiedChannel) +} From 8a13eaccc061256910c76a53d80cb4d8a511c489 Mon Sep 17 00:00:00 2001 From: Aleksandr Pismenskiy Date: Thu, 19 Dec 2024 19:19:17 +0300 Subject: [PATCH 14/25] v5.0.5 upgrade handler --- app/app.go | 2 ++ app/upgrades/v5.0.5/constants.go | 18 ++++++++++++++ app/upgrades/v5.0.5/upgrades.go | 35 ++++++++++++++++++++++++++ app/upgrades/v5.0.5/upgrades_test.go | 37 ++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 app/upgrades/v5.0.5/constants.go create mode 100644 app/upgrades/v5.0.5/upgrades.go create mode 100644 app/upgrades/v5.0.5/upgrades_test.go diff --git a/app/app.go b/app/app.go index 30967e9f4..738bc66f9 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,7 @@ import ( v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2" v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" + v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types" "github.com/skip-mev/feemarket/x/feemarket" @@ -232,6 +233,7 @@ var ( v500.Upgrade, v502.Upgrade, v504.Upgrade, + v505.Upgrade, } // DefaultNodeHome default home directories for the application daemon diff --git a/app/upgrades/v5.0.5/constants.go b/app/upgrades/v5.0.5/constants.go new file mode 100644 index 000000000..5bb7590d9 --- /dev/null +++ b/app/upgrades/v5.0.5/constants.go @@ -0,0 +1,18 @@ +package v505 + +import ( + storetypes "cosmossdk.io/store/types" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v5.0.5" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{}, +} diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go new file mode 100644 index 000000000..fb3fe9444 --- /dev/null +++ b/app/upgrades/v5.0.5/upgrades.go @@ -0,0 +1,35 @@ +package v505 + +import ( + "context" + "fmt" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ *upgrades.UpgradeKeepers, + _ upgrades.StoreKeys, + _ codec.Codec, +) upgradetypes.UpgradeHandler { + return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(c) + + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) + return vm, nil + } +} diff --git a/app/upgrades/v5.0.5/upgrades_test.go b/app/upgrades/v5.0.5/upgrades_test.go new file mode 100644 index 000000000..3590362bd --- /dev/null +++ b/app/upgrades/v5.0.5/upgrades_test.go @@ -0,0 +1,37 @@ +package v505_test + +import ( + "testing" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" + "github.com/neutron-org/neutron/v5/testutil" +) + +type UpgradeTestSuite struct { + testutil.IBCConnectionTestSuite +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (suite *UpgradeTestSuite) SetupTest() { + suite.IBCConnectionTestSuite.SetupTest() +} + +func (suite *UpgradeTestSuite) TestOracleUpgrade() { + app := suite.GetNeutronZoneApp(suite.ChainA) + ctx := suite.ChainA.GetContext().WithChainID("neutron-1") + t := suite.T() + + upgrade := upgradetypes.Plan{ + Name: v505.UpgradeName, + Info: "some text here", + Height: 100, + } + require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) +} From 66925ca06df2e34d55638694de251fb87043f5e8 Mon Sep 17 00:00:00 2001 From: Aleksandr Pismenskiy Date: Thu, 19 Dec 2024 19:53:09 +0300 Subject: [PATCH 15/25] add TestForceTransferToIBCEscrow --- tests/ibc/tokenfactory_test.go | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/ibc/tokenfactory_test.go b/tests/ibc/tokenfactory_test.go index 0402bfef6..fa3e3f160 100644 --- a/tests/ibc/tokenfactory_test.go +++ b/tests/ibc/tokenfactory_test.go @@ -54,6 +54,41 @@ func (s *TokenfactoryTestSuite) TestForceTransferFromIBCEscrow() { s.Assert().ErrorContains(err, "force transfer from IBC escrow accounts is forbidden") } +func (s *TokenfactoryTestSuite) TestForceTransferToIBCEscrow() { + // Create token factory denom + createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") + _, err := s.neutronChain.SendMsgs(createDenomMsg) + s.Assert().NoError(err) + + // Derive full token factory denom + denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) + + // Mint denom to sender + amount := sdk.NewCoin(denom, math.NewInt(10000000)) + mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) + _, err = s.neutronChain.SendMsgs(mintMsg) + s.Assert().NoError(err) + + // Send IBC transfer + s.IBCTransfer( + s.neutronTransferPath, + s.neutronTransferPath.EndpointA, + s.neutronAddr, + s.providerAddr, + amount.Denom, + amount.Amount, + "", + ) + + // Derive IBC escrow address for channel + escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) + + // Transfer tokens out of escrow address + forceTransferMsg := tftypes.NewMsgForceTransfer(s.neutronAddr.String(), sdk.NewCoin(amount.Denom, amount.Amount), s.neutronAddr.String(), escrowAddress.String()) + _, err = s.neutronChain.SendMsgs(forceTransferMsg) + s.Assert().ErrorContains(err, "force transfer to IBC escrow accounts is forbidden") +} + func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { // Create token factory denom createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") From 3c6f5d6e900951fd41105ab9248d808787462f95 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Thu, 19 Dec 2024 22:35:53 +0000 Subject: [PATCH 16/25] filter channels by port id --- x/tokenfactory/keeper/keeper.go | 2 +- x/tokenfactory/types/expected_keepers.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 23aa80c3c..011480f71 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -104,7 +104,7 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { func (k Keeper) GetAllIBCEscrowAccounts(ctx sdk.Context) map[string]bool { escrowAddresses := make(map[string]bool) - transferChannels := k.channelKeeper.GetAllChannels(ctx) + transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, transfertypes.PortID) for _, channel := range transferChannels { escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) escrowAddresses[escrowAddress.String()] = true diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 8b95d9189..18e66484b 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -43,5 +43,5 @@ type ContractKeeper interface { // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { - GetAllChannels(ctx sdk.Context) (channels []channeltypes.IdentifiedChannel) + GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) (channels []channeltypes.IdentifiedChannel) } From 13fd9f825a11a2bf9ad9353c425afce9cc7a230b Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Thu, 19 Dec 2024 23:05:31 +0000 Subject: [PATCH 17/25] fixed tests --- app/app.go | 1 + testutil/tokenfactory/keeper/tokenfactory.go | 2 ++ x/tokenfactory/keeper/keeper.go | 8 +++++--- x/tokenfactory/keeper/msg_server_test.go | 18 +++++++++--------- x/tokenfactory/types/expected_keepers.go | 5 +++++ 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index 738bc66f9..f4455e490 100644 --- a/app/app.go +++ b/app/app.go @@ -697,6 +697,7 @@ func New( &app.WasmKeeper, authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), app.IBCKeeper.ChannelKeeper, + app.TransferKeeper.Keeper, ) app.TokenFactoryKeeper = &tokenFactoryKeeper diff --git a/testutil/tokenfactory/keeper/tokenfactory.go b/testutil/tokenfactory/keeper/tokenfactory.go index 67bae4639..e39125a26 100644 --- a/testutil/tokenfactory/keeper/tokenfactory.go +++ b/testutil/tokenfactory/keeper/tokenfactory.go @@ -25,6 +25,7 @@ func TokenFactoryKeeper( bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, channelKeeper types.ChannelKeeper, + transferKeeper types.TransferKeeper, ) (keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -47,6 +48,7 @@ func TokenFactoryKeeper( contractKeeper, testutil.TestOwnerAddress, channelKeeper, + transferKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 011480f71..7775b836e 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "sort" "cosmossdk.io/log" @@ -10,8 +11,6 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - "github.com/neutron-org/neutron/v5/x/tokenfactory/types" ) @@ -25,6 +24,7 @@ type ( contractKeeper types.ContractKeeper authority string channelKeeper types.ChannelKeeper + transferKeeper types.TransferKeeper } ) @@ -38,6 +38,7 @@ func NewKeeper( contractKeeper types.ContractKeeper, authority string, channelKeeper types.ChannelKeeper, + transferKeeper types.TransferKeeper, ) Keeper { sortedKnownModules := make([]string, 0, len(maccPerms)) for moduleName := range maccPerms { @@ -54,6 +55,7 @@ func NewKeeper( contractKeeper: contractKeeper, authority: authority, channelKeeper: channelKeeper, + transferKeeper: transferKeeper, } } @@ -104,7 +106,7 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { func (k Keeper) GetAllIBCEscrowAccounts(ctx sdk.Context) map[string]bool { escrowAddresses := make(map[string]bool) - transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, transfertypes.PortID) + transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, k.transferKeeper.GetPort(ctx)) for _, channel := range transferChannels { escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) escrowAddresses[escrowAddress.String()] = true diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index e07ba0aa0..ef41cec97 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -23,7 +23,7 @@ const ( ) func TestMsgCreateDenomValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -68,7 +68,7 @@ func TestMsgCreateDenomValidate(t *testing.T) { } func TestMsgMintValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -162,7 +162,7 @@ func TestMsgMintValidate(t *testing.T) { } func TestMsgBurnValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -256,7 +256,7 @@ func TestMsgBurnValidate(t *testing.T) { } func TestMsgForceTransferValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -375,7 +375,7 @@ func TestMsgForceTransferValidate(t *testing.T) { } func TestMsgChangeAdminValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -450,7 +450,7 @@ func TestMsgChangeAdminValidate(t *testing.T) { } func TestMsgSetDenomMetadataValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -781,7 +781,7 @@ func TestMsgSetDenomMetadataValidate(t *testing.T) { } func TestMsgSetBeforeSendHookValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -847,7 +847,7 @@ func TestMsgSetBeforeSendHookValidate(t *testing.T) { } func TestMsgUpdateParamsValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) tests := []struct { name string @@ -913,7 +913,7 @@ func TestMsgUpdateParamsValidate(t *testing.T) { } func TestMsgUpdateParamsWhitelistedHooks(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) tests := []struct { name string diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 18e66484b..7559ea7ba 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -45,3 +45,8 @@ type ContractKeeper interface { type ChannelKeeper interface { GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) (channels []channeltypes.IdentifiedChannel) } + +// TransferKeeper defines the expected IBC Transfer keeper +type TransferKeeper interface { + GetPort(ctx sdk.Context) string +} From b3c00a20832c259d3f861da97c0a56ee2bdfc7a1 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Fri, 20 Dec 2024 13:53:36 +0000 Subject: [PATCH 18/25] better tests --- app/app.go | 27 ++++----- app/upgrades/types.go | 2 + app/upgrades/v5.0.5/upgrades.go | 9 ++- .../contractmanager/types/expected_keepers.go | 1 - .../mocks/interchainqueries/keeper/verify.go | 1 - .../interchaintxs/types/expected_keepers.go | 1 - .../mocks/transfer/types/expected_keepers.go | 36 +++++++++++- testutil/tokenfactory/keeper/tokenfactory.go | 4 -- x/tokenfactory/keeper/bankactions.go | 10 +--- x/tokenfactory/keeper/escrow_addresses.go | 21 +++++++ x/tokenfactory/keeper/keeper.go | 19 ------- x/tokenfactory/keeper/msg_server_test.go | 18 +++--- x/tokenfactory/types/expected_keepers.go | 11 ---- x/tokenfactory/types/keys.go | 2 + x/transfer/ibc_handlers_test.go | 7 ++- x/transfer/keeper/keeper.go | 2 - x/transfer/module.go | 57 +++++++++++++++---- x/transfer/types/expected_keepers.go | 5 ++ 18 files changed, 151 insertions(+), 82 deletions(-) create mode 100644 x/tokenfactory/keeper/escrow_addresses.go diff --git a/app/app.go b/app/app.go index f4455e490..0772f0f59 100644 --- a/app/app.go +++ b/app/app.go @@ -625,6 +625,17 @@ func New( authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), ) + tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( + appCodec, + app.keys[tokenfactorytypes.StoreKey], + maccPerms, + app.AccountKeeper, + &app.BankKeeper, + &app.WasmKeeper, + authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), + ) + app.TokenFactoryKeeper = &tokenFactoryKeeper + app.WireICS20PreWasmKeeper(appCodec) app.PFMModule = packetforward.NewAppModule(app.PFMKeeper, app.GetSubspace(pfmtypes.ModuleName)) @@ -688,19 +699,6 @@ func New( app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) consumerModule := ccvconsumer.NewAppModule(app.ConsumerKeeper, app.GetSubspace(ccvconsumertypes.ModuleName)) - tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( - appCodec, - app.keys[tokenfactorytypes.StoreKey], - maccPerms, - app.AccountKeeper, - &app.BankKeeper, - &app.WasmKeeper, - authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), - app.IBCKeeper.ChannelKeeper, - app.TransferKeeper.Keeper, - ) - app.TokenFactoryKeeper = &tokenFactoryKeeper - app.BankKeeper.BaseSendKeeper = app.BankKeeper.BaseSendKeeper.SetHooks( banktypes.NewMultiBankHooks( app.TokenFactoryKeeper.Hooks(), @@ -1377,6 +1375,8 @@ func (app *App) setupUpgradeHandlers() { DynamicfeesKeeper: app.DynamicFeesKeeper, DexKeeper: &app.DexKeeper, IbcRateLimitKeeper: app.RateLimitingICS4Wrapper.IbcratelimitKeeper, + ChannelKeeper: &app.IBCKeeper.ChannelKeeper, + TransferKeeper: app.TransferKeeper.Keeper, GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName), }, @@ -1726,6 +1726,7 @@ func (app *App) WireICS20PreWasmKeeper( transferSudo.NewIBCModule( app.TransferKeeper, contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper), + app.TokenFactoryKeeper, ), app.PFMKeeper, 0, diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 8c52a43b2..72cf7f709 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -12,6 +12,7 @@ import ( paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper" feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" @@ -69,6 +70,7 @@ type UpgradeKeepers struct { DynamicfeesKeeper *dynamicfeeskeeper.Keeper DexKeeper *dexkeeper.Keeper IbcRateLimitKeeper *ibcratelimitkeeper.Keeper + ChannelKeeper *channelkeeper.Keeper // subspaces GlobalFeeSubspace paramtypes.Subspace CcvConsumerSubspace paramtypes.Subspace diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go index fb3fe9444..0ba93e8f2 100644 --- a/app/upgrades/v5.0.5/upgrades.go +++ b/app/upgrades/v5.0.5/upgrades.go @@ -3,6 +3,7 @@ package v505 import ( "context" "fmt" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/codec" @@ -15,7 +16,7 @@ import ( func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, - _ *upgrades.UpgradeKeepers, + keepers *upgrades.UpgradeKeepers, _ upgrades.StoreKeys, _ codec.Codec, ) upgradetypes.UpgradeHandler { @@ -29,6 +30,12 @@ func CreateUpgradeHandler( return vm, err } + transferChannels := keepers.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, keepers.TransferKeeper.GetPort(ctx)) + for _, channel := range transferChannels { + escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) + keepers.TokenFactoryKeeper.StoreEscrowAddress(ctx, escrowAddress) + } + ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) return vm, nil } diff --git a/testutil/mocks/contractmanager/types/expected_keepers.go b/testutil/mocks/contractmanager/types/expected_keepers.go index 5d2ef0a4f..7ff82c05c 100644 --- a/testutil/mocks/contractmanager/types/expected_keepers.go +++ b/testutil/mocks/contractmanager/types/expected_keepers.go @@ -11,7 +11,6 @@ import ( types "github.com/CosmWasm/wasmd/x/wasm/types" types0 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/contractmanager/types" ) diff --git a/testutil/mocks/interchainqueries/keeper/verify.go b/testutil/mocks/interchainqueries/keeper/verify.go index 02f03e7d9..b8cb86c6e 100644 --- a/testutil/mocks/interchainqueries/keeper/verify.go +++ b/testutil/mocks/interchainqueries/keeper/verify.go @@ -13,7 +13,6 @@ import ( exported "github.com/cosmos/ibc-go/v8/modules/core/exported" tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/interchainqueries/types" ) diff --git a/testutil/mocks/interchaintxs/types/expected_keepers.go b/testutil/mocks/interchaintxs/types/expected_keepers.go index 0c1d7c3b1..67cc758ab 100644 --- a/testutil/mocks/interchaintxs/types/expected_keepers.go +++ b/testutil/mocks/interchaintxs/types/expected_keepers.go @@ -14,7 +14,6 @@ import ( types2 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" exported "github.com/cosmos/ibc-go/v8/modules/core/exported" gomock "github.com/golang/mock/gomock" - types3 "github.com/neutron-org/neutron/v5/x/feerefunder/types" ) diff --git a/testutil/mocks/transfer/types/expected_keepers.go b/testutil/mocks/transfer/types/expected_keepers.go index 9e952f77b..4789cb264 100644 --- a/testutil/mocks/transfer/types/expected_keepers.go +++ b/testutil/mocks/transfer/types/expected_keepers.go @@ -11,7 +11,6 @@ import ( types "github.com/cosmos/cosmos-sdk/types" types0 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/feerefunder/types" ) @@ -245,3 +244,38 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), name) } + +// MockTokenfactoryKeeper is a mock of TokenfactoryKeeper interface. +type MockTokenfactoryKeeper struct { + ctrl *gomock.Controller + recorder *MockTokenfactoryKeeperMockRecorder +} + +// MockTokenfactoryKeeperMockRecorder is the mock recorder for MockTokenfactoryKeeper. +type MockTokenfactoryKeeperMockRecorder struct { + mock *MockTokenfactoryKeeper +} + +// NewMockTokenfactoryKeeper creates a new mock instance. +func NewMockTokenfactoryKeeper(ctrl *gomock.Controller) *MockTokenfactoryKeeper { + mock := &MockTokenfactoryKeeper{ctrl: ctrl} + mock.recorder = &MockTokenfactoryKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTokenfactoryKeeper) EXPECT() *MockTokenfactoryKeeperMockRecorder { + return m.recorder +} + +// StoreEscrowAddress mocks base method. +func (m *MockTokenfactoryKeeper) StoreEscrowAddress(ctx types.Context, address types.AccAddress) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "StoreEscrowAddress", ctx, address) +} + +// StoreEscrowAddress indicates an expected call of StoreEscrowAddress. +func (mr *MockTokenfactoryKeeperMockRecorder) StoreEscrowAddress(ctx, address interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreEscrowAddress", reflect.TypeOf((*MockTokenfactoryKeeper)(nil).StoreEscrowAddress), ctx, address) +} diff --git a/testutil/tokenfactory/keeper/tokenfactory.go b/testutil/tokenfactory/keeper/tokenfactory.go index e39125a26..f65b1ab31 100644 --- a/testutil/tokenfactory/keeper/tokenfactory.go +++ b/testutil/tokenfactory/keeper/tokenfactory.go @@ -24,8 +24,6 @@ func TokenFactoryKeeper( accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, - channelKeeper types.ChannelKeeper, - transferKeeper types.TransferKeeper, ) (keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -47,8 +45,6 @@ func TokenFactoryKeeper( bankKeeper, contractKeeper, testutil.TestOwnerAddress, - channelKeeper, - transferKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index e0f4ae7de..552bbdb0c 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -50,9 +50,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } - escrowAccounts := k.GetAllIBCEscrowAccounts(ctx) - - if _, ok := escrowAccounts[burnFromAcc.String()]; ok { + if k.isEscrowAddress(ctx, burnFromAcc) { return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") } @@ -92,13 +90,11 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } - escrowAccounts := k.GetAllIBCEscrowAccounts(ctx) - - if _, ok := escrowAccounts[transferFromAcc.String()]; ok { + if k.isEscrowAddress(ctx, transferFromAcc) { return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") } - if _, ok := escrowAccounts[transferToAcc.String()]; ok { + if k.isEscrowAddress(ctx, transferToAcc) { return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/escrow_addresses.go b/x/tokenfactory/keeper/escrow_addresses.go new file mode 100644 index 000000000..a4af97a13 --- /dev/null +++ b/x/tokenfactory/keeper/escrow_addresses.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/v5/x/tokenfactory/types" +) + +// StoreEscrowAddress sets the total set of params. +func (k Keeper) StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) + + prefixStore.Set(address.Bytes(), []byte{0}) +} + +func (k Keeper) isEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) + bz := prefixStore.Get(address.Bytes()) + + return len(bz) != 0 +} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 7775b836e..aae912cb2 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "context" "fmt" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "sort" "cosmossdk.io/log" @@ -23,8 +22,6 @@ type ( bankKeeper types.BankKeeper contractKeeper types.ContractKeeper authority string - channelKeeper types.ChannelKeeper - transferKeeper types.TransferKeeper } ) @@ -37,8 +34,6 @@ func NewKeeper( bankKeeper types.BankKeeper, contractKeeper types.ContractKeeper, authority string, - channelKeeper types.ChannelKeeper, - transferKeeper types.TransferKeeper, ) Keeper { sortedKnownModules := make([]string, 0, len(maccPerms)) for moduleName := range maccPerms { @@ -54,8 +49,6 @@ func NewKeeper( bankKeeper: bankKeeper, contractKeeper: contractKeeper, authority: authority, - channelKeeper: channelKeeper, - transferKeeper: transferKeeper, } } @@ -102,15 +95,3 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context) { // GetModuleAccount creates new module account if not present under the hood k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) } - -func (k Keeper) GetAllIBCEscrowAccounts(ctx sdk.Context) map[string]bool { - escrowAddresses := make(map[string]bool) - - transferChannels := k.channelKeeper.GetAllChannelsWithPortPrefix(ctx, k.transferKeeper.GetPort(ctx)) - for _, channel := range transferChannels { - escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) - escrowAddresses[escrowAddress.String()] = true - } - - return escrowAddresses -} diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index ef41cec97..70bd4158d 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -23,7 +23,7 @@ const ( ) func TestMsgCreateDenomValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -68,7 +68,7 @@ func TestMsgCreateDenomValidate(t *testing.T) { } func TestMsgMintValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -162,7 +162,7 @@ func TestMsgMintValidate(t *testing.T) { } func TestMsgBurnValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -256,7 +256,7 @@ func TestMsgBurnValidate(t *testing.T) { } func TestMsgForceTransferValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -375,7 +375,7 @@ func TestMsgForceTransferValidate(t *testing.T) { } func TestMsgChangeAdminValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -450,7 +450,7 @@ func TestMsgChangeAdminValidate(t *testing.T) { } func TestMsgSetDenomMetadataValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -781,7 +781,7 @@ func TestMsgSetDenomMetadataValidate(t *testing.T) { } func TestMsgSetBeforeSendHookValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) msgServer := keeper.NewMsgServerImpl(k) tests := []struct { @@ -847,7 +847,7 @@ func TestMsgSetBeforeSendHookValidate(t *testing.T) { } func TestMsgUpdateParamsValidate(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) tests := []struct { name string @@ -913,7 +913,7 @@ func TestMsgUpdateParamsValidate(t *testing.T) { } func TestMsgUpdateParamsWhitelistedHooks(t *testing.T) { - k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil, nil, nil) + k, ctx := testkeeper.TokenFactoryKeeper(t, nil, nil, nil) tests := []struct { name string diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 7559ea7ba..45e7d8b0e 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -6,7 +6,6 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) type BankKeeper interface { @@ -40,13 +39,3 @@ type ContractKeeper interface { Sudo(ctx context.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) GetContractInfo(ctx context.Context, contractAddress sdk.AccAddress) *wasmtypes.ContractInfo } - -// ChannelKeeper defines the expected IBC channel keeper -type ChannelKeeper interface { - GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) (channels []channeltypes.IdentifiedChannel) -} - -// TransferKeeper defines the expected IBC Transfer keeper -type TransferKeeper interface { - GetPort(ctx sdk.Context) string -} diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go index 8bfeb012c..543775fdc 100644 --- a/x/tokenfactory/types/keys.go +++ b/x/tokenfactory/types/keys.go @@ -25,6 +25,7 @@ const ( const ( KeySeparator = "|" prefixParamsKey = iota + 1 + prefixEscrowAddressKey ) var ( @@ -34,6 +35,7 @@ var ( AdminPrefixKey = "admin" BeforeSendHookAddressPrefixKey = "beforesendhook" ParamsKey = []byte{prefixParamsKey} + EscrowAddressKey = []byte{prefixEscrowAddressKey} ) // GetDenomPrefixStore returns the store prefix where all the data associated with a specific denom diff --git a/x/transfer/ibc_handlers_test.go b/x/transfer/ibc_handlers_test.go index e6ccadc1a..e73b99be0 100644 --- a/x/transfer/ibc_handlers_test.go +++ b/x/transfer/ibc_handlers_test.go @@ -31,10 +31,12 @@ func TestHandleAcknowledgement(t *testing.T) { feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl) chanKeeper := mock_types.NewMockChannelKeeper(ctrl) authKeeper := mock_types.NewMockAccountKeeper(ctrl) + tokenfactoryKeeper := mock_types.NewMockTokenfactoryKeeper(ctrl) + // required to initialize keeper authKeeper.EXPECT().GetModuleAddress(transfertypes.ModuleName).Return([]byte("address")) txKeeper, infCtx, _ := testkeeper.TransferKeeper(t, wmKeeper, feeKeeper, chanKeeper, authKeeper) - txModule := transfer.NewIBCModule(*txKeeper, wmKeeper) + txModule := transfer.NewIBCModule(*txKeeper, wmKeeper, tokenfactoryKeeper) ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000)) resACK := channeltypes.Acknowledgement{ @@ -114,10 +116,11 @@ func TestHandleTimeout(t *testing.T) { feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl) chanKeeper := mock_types.NewMockChannelKeeper(ctrl) authKeeper := mock_types.NewMockAccountKeeper(ctrl) + tokenfactoryKeeper := mock_types.NewMockTokenfactoryKeeper(ctrl) // required to initialize keeper authKeeper.EXPECT().GetModuleAddress(transfertypes.ModuleName).Return([]byte("address")) txKeeper, infCtx, _ := testkeeper.TransferKeeper(t, wmKeeper, feeKeeper, chanKeeper, authKeeper) - txModule := transfer.NewIBCModule(*txKeeper, wmKeeper) + txModule := transfer.NewIBCModule(*txKeeper, wmKeeper, tokenfactoryKeeper) ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000)) contractAddress := sdk.MustAccAddressFromBech32(testutil.TestOwnerAddress) relayerBech32 := "neutron1fxudpred77a0grgh69u0j7y84yks5ev4n5050z45kecz792jnd6scqu98z" diff --git a/x/transfer/keeper/keeper.go b/x/transfer/keeper/keeper.go index 191a1ae4f..bd2e8838e 100644 --- a/x/transfer/keeper/keeper.go +++ b/x/transfer/keeper/keeper.go @@ -2,10 +2,8 @@ package transfer import ( "context" - "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/transfer/module.go b/x/transfer/module.go index 0479b53b5..e925ae92d 100644 --- a/x/transfer/module.go +++ b/x/transfer/module.go @@ -1,10 +1,10 @@ package transfer import ( - "fmt" - "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" + "fmt" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -25,19 +25,21 @@ import ( */ type IBCModule struct { - wrappedKeeper wrapkeeper.KeeperTransferWrapper - keeper keeper.Keeper - sudoKeeper neutrontypes.WasmKeeper + wrappedKeeper wrapkeeper.KeeperTransferWrapper + keeper keeper.Keeper + sudoKeeper neutrontypes.WasmKeeper + tokenfactoryKeeper neutrontypes.TokenfactoryKeeper transfer.IBCModule } // NewIBCModule creates a new IBCModule given the keeper -func NewIBCModule(k wrapkeeper.KeeperTransferWrapper, sudoKeeper neutrontypes.WasmKeeper) IBCModule { +func NewIBCModule(k wrapkeeper.KeeperTransferWrapper, sudoKeeper neutrontypes.WasmKeeper, tokenfactoryKeeper neutrontypes.TokenfactoryKeeper) IBCModule { return IBCModule{ - wrappedKeeper: k, - keeper: k.Keeper, - sudoKeeper: sudoKeeper, - IBCModule: transfer.NewIBCModule(k.Keeper), + wrappedKeeper: k, + keeper: k.Keeper, + sudoKeeper: sudoKeeper, + IBCModule: transfer.NewIBCModule(k.Keeper), + tokenfactoryKeeper: tokenfactoryKeeper, } } @@ -69,6 +71,41 @@ func (im IBCModule) OnTimeoutPacket( return im.HandleTimeout(ctx, packet, relayer) } +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _ string, + counterpartyVersion string, +) error { + err := im.IBCModule.OnChanOpenAck(ctx, portID, channelID, "", counterpartyVersion) + if err != nil { + return errors.Wrap(err, "failed to process original OnChanOpenAck") + } + + escrowAddress := transfertypes.GetEscrowAddress(portID, channelID) + im.tokenfactoryKeeper.StoreEscrowAddress(ctx, escrowAddress.Bytes()) + + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + err := im.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) + if err != nil { + return errors.Wrap(err, "failed to process original OnChanOpenConfirm") + } + + escrowAddress := transfertypes.GetEscrowAddress(portID, channelID) + im.tokenfactoryKeeper.StoreEscrowAddress(ctx, escrowAddress.Bytes()) + + return nil +} + var _ appmodule.AppModule = AppModule{} type AppModule struct { diff --git a/x/transfer/types/expected_keepers.go b/x/transfer/types/expected_keepers.go index 5eb6f8edc..8642079fc 100644 --- a/x/transfer/types/expected_keepers.go +++ b/x/transfer/types/expected_keepers.go @@ -32,3 +32,8 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI } + +// TokenfactoryKeeper defines the tokenfactory keeper. +type TokenfactoryKeeper interface { + StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) +} From 6faa789afee0deef7a7074cb890ff7fbe03ddd78 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Fri, 20 Dec 2024 14:07:32 +0000 Subject: [PATCH 19/25] better logging --- app/upgrades/v5.0.5/upgrades.go | 2 ++ app/upgrades/v5.0.5/upgrades_test.go | 16 +++++++++++++++- x/tokenfactory/keeper/bankactions.go | 6 +++--- x/tokenfactory/keeper/escrow_addresses.go | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go index 0ba93e8f2..112225a24 100644 --- a/app/upgrades/v5.0.5/upgrades.go +++ b/app/upgrades/v5.0.5/upgrades.go @@ -33,6 +33,8 @@ func CreateUpgradeHandler( transferChannels := keepers.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, keepers.TransferKeeper.GetPort(ctx)) for _, channel := range transferChannels { escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) + ctx.Logger().Info("Saving escrow address", "port_id", channel.PortId, "channel_id", + channel.ChannelId, "address", escrowAddress.String()) keepers.TokenFactoryKeeper.StoreEscrowAddress(ctx, escrowAddress) } diff --git a/app/upgrades/v5.0.5/upgrades_test.go b/app/upgrades/v5.0.5/upgrades_test.go index 3590362bd..be9cbde86 100644 --- a/app/upgrades/v5.0.5/upgrades_test.go +++ b/app/upgrades/v5.0.5/upgrades_test.go @@ -1,6 +1,8 @@ package v505_test import ( + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "testing" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -23,7 +25,7 @@ func (suite *UpgradeTestSuite) SetupTest() { suite.IBCConnectionTestSuite.SetupTest() } -func (suite *UpgradeTestSuite) TestOracleUpgrade() { +func (suite *UpgradeTestSuite) TestUpgrade() { app := suite.GetNeutronZoneApp(suite.ChainA) ctx := suite.ChainA.GetContext().WithChainID("neutron-1") t := suite.T() @@ -33,5 +35,17 @@ func (suite *UpgradeTestSuite) TestOracleUpgrade() { Info: "some text here", Height: 100, } + + var escrowAddresses []sdk.AccAddress + transferChannels := app.IBCKeeper.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, app.TransferKeeper.GetPort(ctx)) + for _, channel := range transferChannels { + escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)) + } + require.Greater(t, len(escrowAddresses), 0) require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) + + for _, escrowAddress := range escrowAddresses { + require.True(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, escrowAddress)) + } + require.False(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, []byte{1, 2, 3, 4, 5})) } diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 552bbdb0c..e9bc92171 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -50,7 +50,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } - if k.isEscrowAddress(ctx, burnFromAcc) { + if k.IsEscrowAddress(ctx, burnFromAcc) { return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") } @@ -90,11 +90,11 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } - if k.isEscrowAddress(ctx, transferFromAcc) { + if k.IsEscrowAddress(ctx, transferFromAcc) { return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") } - if k.isEscrowAddress(ctx, transferToAcc) { + if k.IsEscrowAddress(ctx, transferToAcc) { return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/escrow_addresses.go b/x/tokenfactory/keeper/escrow_addresses.go index a4af97a13..5189a3e7d 100644 --- a/x/tokenfactory/keeper/escrow_addresses.go +++ b/x/tokenfactory/keeper/escrow_addresses.go @@ -13,7 +13,7 @@ func (k Keeper) StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) { prefixStore.Set(address.Bytes(), []byte{0}) } -func (k Keeper) isEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { +func (k Keeper) IsEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) bz := prefixStore.Get(address.Bytes()) From 5a180b72b291ab358c52cdb41ae591cbe6a8d3b1 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Fri, 20 Dec 2024 14:16:20 +0000 Subject: [PATCH 20/25] fixed tests --- tests/ibc/tokenfactory_test.go | 2 +- x/tokenfactory/keeper/bankactions.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/ibc/tokenfactory_test.go b/tests/ibc/tokenfactory_test.go index fa3e3f160..20dc3c22b 100644 --- a/tests/ibc/tokenfactory_test.go +++ b/tests/ibc/tokenfactory_test.go @@ -121,5 +121,5 @@ func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { // Burn tokens from escrow address burnMsg := tftypes.NewMsgBurnFrom(s.neutronAddr.String(), amount, escrowAddress.String()) _, err = s.neutronChain.SendMsgs(burnMsg) - s.Assert().ErrorContains(err, "burning from escrow accounts is forbidden") + s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden") } diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index e9bc92171..7960c42e3 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -24,6 +24,10 @@ func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { return status.Errorf(codes.Internal, "minting to module accounts is forbidden") } + if k.IsEscrowAddress(ctx, mintToAcc) { + return status.Errorf(codes.Internal, "minting to IBC escrow accounts is forbidden") + } + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) if err != nil { return err @@ -51,7 +55,7 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro } if k.IsEscrowAddress(ctx, burnFromAcc) { - return status.Errorf(codes.Internal, "burning from escrow accounts is forbidden") + return status.Errorf(codes.Internal, "burning from IBC escrow accounts is forbidden") } err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, From f3bd034a118ab00552ae5c064e5f4200e342d1a5 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Fri, 20 Dec 2024 16:05:30 +0000 Subject: [PATCH 21/25] additional test --- tests/ibc/tokenfactory_test.go | 48 +++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/ibc/tokenfactory_test.go b/tests/ibc/tokenfactory_test.go index 20dc3c22b..22f7cfb6e 100644 --- a/tests/ibc/tokenfactory_test.go +++ b/tests/ibc/tokenfactory_test.go @@ -15,7 +15,7 @@ type TokenfactoryTestSuite struct { IBCTestSuite } -func TestPocTestSuite(t *testing.T) { +func TestTokenfactoryTestSuite(t *testing.T) { suite.Run(t, new(TokenfactoryTestSuite)) } @@ -123,3 +123,49 @@ func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { _, err = s.neutronChain.SendMsgs(burnMsg) s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden") } + +func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrowReverse() { + // Create token factory denom + createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") + _, err := s.neutronChain.SendMsgs(createDenomMsg) + s.Assert().NoError(err) + + // Derive full token factory denom + denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) + + // Mint denom to sender + amount := sdk.NewCoin(denom, math.NewInt(10000000)) + mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) + _, err = s.neutronChain.SendMsgs(mintMsg) + s.Assert().NoError(err) + + // Send IBC transfer + s.IBCTransfer( + s.neutronChainBPath, + s.neutronChainBPath.EndpointA, + s.neutronAddr, + s.neutronAddr, + amount.Denom, + amount.Amount, + "", + ) + + // Create token factory denom + createDenomMsg = tftypes.NewMsgCreateDenom(s.bundleB.Chain.SenderAccount.GetAddress().String(), "testtest") + _, err = s.bundleB.Chain.SendMsgs(createDenomMsg) + s.Assert().NoError(err) + + // Derive IBC escrow address for channel + escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronChainBPath.EndpointB.ChannelID) + + // Derive full token factory denom + denom = fmt.Sprintf("factory/%s/%s", s.bundleB.Chain.SenderAccount.GetAddress().String(), createDenomMsg.Subdenom) + + // Mint denom to sender + amount = sdk.NewCoin(denom, math.NewInt(10000000)) + + // Burn tokens from escrow address + burnMsg := tftypes.NewMsgBurnFrom(s.bundleB.Chain.SenderAccount.GetAddress().String(), amount, escrowAddress.String()) + _, err = s.bundleB.Chain.SendMsgs(burnMsg) + s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden") +} From 58d5ec1768718578c15bce3e8d778cb024456d64 Mon Sep 17 00:00:00 2001 From: sotnikov-s Date: Fri, 20 Dec 2024 19:12:28 +0300 Subject: [PATCH 22/25] rm tf test to move to integration test --- tests/ibc/tokenfactory_test.go | 171 --------------------------------- 1 file changed, 171 deletions(-) delete mode 100644 tests/ibc/tokenfactory_test.go diff --git a/tests/ibc/tokenfactory_test.go b/tests/ibc/tokenfactory_test.go deleted file mode 100644 index 22f7cfb6e..000000000 --- a/tests/ibc/tokenfactory_test.go +++ /dev/null @@ -1,171 +0,0 @@ -package ibc_test - -import ( - "fmt" - "testing" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - tftypes "github.com/neutron-org/neutron/v5/x/tokenfactory/types" - "github.com/stretchr/testify/suite" -) - -type TokenfactoryTestSuite struct { - IBCTestSuite -} - -func TestTokenfactoryTestSuite(t *testing.T) { - suite.Run(t, new(TokenfactoryTestSuite)) -} - -func (s *TokenfactoryTestSuite) TestForceTransferFromIBCEscrow() { - // Create token factory denom - createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") - _, err := s.neutronChain.SendMsgs(createDenomMsg) - s.Assert().NoError(err) - - // Derive full token factory denom - denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) - - // Mint denom to sender - amount := sdk.NewCoin(denom, math.NewInt(10000000)) - mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) - _, err = s.neutronChain.SendMsgs(mintMsg) - s.Assert().NoError(err) - - // Send IBC transfer - s.IBCTransfer( - s.neutronTransferPath, - s.neutronTransferPath.EndpointA, - s.neutronAddr, - s.providerAddr, - amount.Denom, - amount.Amount, - "", - ) - - // Derive IBC escrow address for channel - escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) - - // Transfer tokens out of escrow address - forceTransferMsg := tftypes.NewMsgForceTransfer(s.neutronAddr.String(), sdk.NewCoin(amount.Denom, amount.Amount), escrowAddress.String(), s.neutronAddr.String()) - _, err = s.neutronChain.SendMsgs(forceTransferMsg) - s.Assert().ErrorContains(err, "force transfer from IBC escrow accounts is forbidden") -} - -func (s *TokenfactoryTestSuite) TestForceTransferToIBCEscrow() { - // Create token factory denom - createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") - _, err := s.neutronChain.SendMsgs(createDenomMsg) - s.Assert().NoError(err) - - // Derive full token factory denom - denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) - - // Mint denom to sender - amount := sdk.NewCoin(denom, math.NewInt(10000000)) - mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) - _, err = s.neutronChain.SendMsgs(mintMsg) - s.Assert().NoError(err) - - // Send IBC transfer - s.IBCTransfer( - s.neutronTransferPath, - s.neutronTransferPath.EndpointA, - s.neutronAddr, - s.providerAddr, - amount.Denom, - amount.Amount, - "", - ) - - // Derive IBC escrow address for channel - escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) - - // Transfer tokens out of escrow address - forceTransferMsg := tftypes.NewMsgForceTransfer(s.neutronAddr.String(), sdk.NewCoin(amount.Denom, amount.Amount), s.neutronAddr.String(), escrowAddress.String()) - _, err = s.neutronChain.SendMsgs(forceTransferMsg) - s.Assert().ErrorContains(err, "force transfer to IBC escrow accounts is forbidden") -} - -func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrow() { - // Create token factory denom - createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") - _, err := s.neutronChain.SendMsgs(createDenomMsg) - s.Assert().NoError(err) - - // Derive full token factory denom - denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) - - // Mint denom to sender - amount := sdk.NewCoin(denom, math.NewInt(10000000)) - mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) - _, err = s.neutronChain.SendMsgs(mintMsg) - s.Assert().NoError(err) - - // Send IBC transfer - s.IBCTransfer( - s.neutronTransferPath, - s.neutronTransferPath.EndpointA, - s.neutronAddr, - s.providerAddr, - amount.Denom, - amount.Amount, - "", - ) - - // Derive IBC escrow address for channel - escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronTransferPath.EndpointA.ChannelID) - - // Burn tokens from escrow address - burnMsg := tftypes.NewMsgBurnFrom(s.neutronAddr.String(), amount, escrowAddress.String()) - _, err = s.neutronChain.SendMsgs(burnMsg) - s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden") -} - -func (s *TokenfactoryTestSuite) TestBurnFromIBCEscrowReverse() { - // Create token factory denom - createDenomMsg := tftypes.NewMsgCreateDenom(s.neutronAddr.String(), "testtest") - _, err := s.neutronChain.SendMsgs(createDenomMsg) - s.Assert().NoError(err) - - // Derive full token factory denom - denom := fmt.Sprintf("factory/%s/%s", createDenomMsg.Sender, createDenomMsg.Subdenom) - - // Mint denom to sender - amount := sdk.NewCoin(denom, math.NewInt(10000000)) - mintMsg := tftypes.NewMsgMint(createDenomMsg.Sender, amount) - _, err = s.neutronChain.SendMsgs(mintMsg) - s.Assert().NoError(err) - - // Send IBC transfer - s.IBCTransfer( - s.neutronChainBPath, - s.neutronChainBPath.EndpointA, - s.neutronAddr, - s.neutronAddr, - amount.Denom, - amount.Amount, - "", - ) - - // Create token factory denom - createDenomMsg = tftypes.NewMsgCreateDenom(s.bundleB.Chain.SenderAccount.GetAddress().String(), "testtest") - _, err = s.bundleB.Chain.SendMsgs(createDenomMsg) - s.Assert().NoError(err) - - // Derive IBC escrow address for channel - escrowAddress := transfertypes.GetEscrowAddress("transfer", s.neutronChainBPath.EndpointB.ChannelID) - - // Derive full token factory denom - denom = fmt.Sprintf("factory/%s/%s", s.bundleB.Chain.SenderAccount.GetAddress().String(), createDenomMsg.Subdenom) - - // Mint denom to sender - amount = sdk.NewCoin(denom, math.NewInt(10000000)) - - // Burn tokens from escrow address - burnMsg := tftypes.NewMsgBurnFrom(s.bundleB.Chain.SenderAccount.GetAddress().String(), amount, escrowAddress.String()) - _, err = s.bundleB.Chain.SendMsgs(burnMsg) - s.Assert().ErrorContains(err, "burning from IBC escrow accounts is forbidden") -} From 4f6b9553e4ee45b0020a598d12ade23e7430184b Mon Sep 17 00:00:00 2001 From: sotnikov-s Date: Fri, 20 Dec 2024 19:28:34 +0300 Subject: [PATCH 23/25] fix duplicated import of package --- x/transfer/module.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x/transfer/module.go b/x/transfer/module.go index e925ae92d..e26810739 100644 --- a/x/transfer/module.go +++ b/x/transfer/module.go @@ -1,9 +1,10 @@ package transfer import ( + "fmt" + "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" - "fmt" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/cosmos/cosmos-sdk/codec" @@ -12,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/ibc-go/v8/modules/apps/transfer" "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" - "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" wrapkeeper "github.com/neutron-org/neutron/v5/x/transfer/keeper" @@ -131,25 +131,25 @@ func (am AppModule) IsAppModule() { // marker // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + transfertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) neutrontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) cfg.MsgServer().RegisterService(&neutrontypes.MsgServiceDescOrig, am.keeper) m := keeper.NewMigrator(am.keeper.Keeper) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.MigrateTraces); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 1, m.MigrateTraces); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 1 to 2: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 2, m.MigrateTotalEscrowForDenom); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 2, m.MigrateTotalEscrowForDenom); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 2 to 3: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 3, m.MigrateParams); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 3, m.MigrateParams); err != nil { panic(fmt.Sprintf("failed to migrate transfer app version 3 to 4: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 4, m.MigrateDenomMetadata); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 4, m.MigrateDenomMetadata); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 4 to 5: %v", err)) } } From 9c3a5c13a5a189b40673dc6f74e7e9ae91e0d20e Mon Sep 17 00:00:00 2001 From: sotnikov-s Date: Fri, 20 Dec 2024 19:36:13 +0300 Subject: [PATCH 24/25] fix lint errors --- app/upgrades/v5.0.5/upgrades.go | 1 + app/upgrades/v5.0.5/upgrades_test.go | 3 ++- x/transfer/keeper/keeper.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go index 112225a24..e90ebc332 100644 --- a/app/upgrades/v5.0.5/upgrades.go +++ b/app/upgrades/v5.0.5/upgrades.go @@ -3,6 +3,7 @@ package v505 import ( "context" "fmt" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" upgradetypes "cosmossdk.io/x/upgrade/types" diff --git a/app/upgrades/v5.0.5/upgrades_test.go b/app/upgrades/v5.0.5/upgrades_test.go index be9cbde86..b65e60b3a 100644 --- a/app/upgrades/v5.0.5/upgrades_test.go +++ b/app/upgrades/v5.0.5/upgrades_test.go @@ -1,9 +1,10 @@ package v505_test import ( + "testing" + sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - "testing" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/stretchr/testify/require" diff --git a/x/transfer/keeper/keeper.go b/x/transfer/keeper/keeper.go index bd2e8838e..15a70efea 100644 --- a/x/transfer/keeper/keeper.go +++ b/x/transfer/keeper/keeper.go @@ -2,6 +2,7 @@ package transfer import ( "context" + "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" From a2d1372d6162442fb2eb6f63aa9c83121b1c3ac3 Mon Sep 17 00:00:00 2001 From: Andrei Zavgorodnii Date: Wed, 1 Jan 2025 13:57:50 +0000 Subject: [PATCH 25/25] updated go.sum --- go.sum | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/go.sum b/go.sum index 4105f4a18..88cb3012c 100644 --- a/go.sum +++ b/go.sum @@ -198,8 +198,8 @@ cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E= cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= -cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= -cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= +cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g= +cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI= cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= @@ -281,6 +281,11 @@ github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/ github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= +github.com/bytedance/sonic v1.12.3 h1:W2MGa7RCU1QTeYRTPE3+88mVC0yXmsRQRChiyVocVjU= +github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= +github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -306,6 +311,10 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -643,8 +652,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 h1:TmHmbvxPmaegwhDubVz0lICL0J5Ka2vwTzhoePEXsGE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= @@ -746,6 +755,9 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -1007,8 +1019,9 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -1019,6 +1032,8 @@ github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= @@ -1090,6 +1105,8 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1229,8 +1246,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1246,8 +1263,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1359,8 +1376,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1606,10 +1623,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 h1:6whtk83KtD3FkGrVb2hFXuQ+ZMbCNdakARIn/aHMmG8= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094/go.mod h1:Zs4wYw8z1zr6RNF4cwYb31mvN/EGaKAdQjNCF3DW6K4= -google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw= -google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 h1:pgr/4QbFyktUv9CtQ/Fq4gzEE6/Xs7iCXbktaGzLHbQ= +google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697/go.mod h1:+D9ySVjN8nY8YCVjc5O7PZDIdZporIDY3KaGfJunh88= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1651,8 +1668,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1715,6 +1732,7 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=