From 2ea19f4faa338123bf507f5c3717a12eaf617468 Mon Sep 17 00:00:00 2001 From: Till Ziegler Date: Tue, 27 Jan 2026 09:19:56 +0100 Subject: [PATCH 1/3] fix: tachyon fix --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 754592902..a1022569b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d github.com/CosmWasm/wasmd v0.46.0 github.com/CosmWasm/wasmvm v1.5.9 - github.com/cometbft/cometbft v0.37.16 + github.com/cometbft/cometbft v0.37.18 github.com/cometbft/cometbft-db v0.11.0 github.com/cosmos/cosmos-sdk v0.47.17 github.com/cosmos/gogoproto v1.7.0 diff --git a/go.sum b/go.sum index 6a3607a35..231e2828b 100644 --- a/go.sum +++ b/go.sum @@ -938,8 +938,8 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= -github.com/cometbft/cometbft v0.37.16 h1:hErtrx8Hz1F/vwQvWsY46PEV8CskWhWzMi3ujp1sNPo= -github.com/cometbft/cometbft v0.37.16/go.mod h1:t/BvwfSJKt2HUHX01L6y1+uw+LOoxU6hFj447wOB5IA= +github.com/cometbft/cometbft v0.37.18 h1:JIjGMHxPqnuoGcCn3gRnmFSCBP6bCIeJWWWILwiDwUk= +github.com/cometbft/cometbft v0.37.18/go.mod h1:t/BvwfSJKt2HUHX01L6y1+uw+LOoxU6hFj447wOB5IA= github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= From 783ddbd57d5b2d8630cb5ff9516d6604249fc511 Mon Sep 17 00:00:00 2001 From: StrathCole Date: Mon, 16 Mar 2026 10:07:10 +0100 Subject: [PATCH 2/3] - legacy code info/code id handling --- custom/wasm/legacy_store.go | 56 +++++++++++++++++++- custom/wasm/query_handler_test.go | 87 +++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 2 deletions(-) diff --git a/custom/wasm/legacy_store.go b/custom/wasm/legacy_store.go index 9a6de6132..fc698c0e5 100644 --- a/custom/wasm/legacy_store.go +++ b/custom/wasm/legacy_store.go @@ -4,6 +4,8 @@ import ( "bytes" "io" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + legacytypes "github.com/classic-terra/core/v3/custom/wasm/types/legacy" coretypes "github.com/classic-terra/core/v3/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -206,10 +208,60 @@ func stripLegacyLenPrefix(b []byte) []byte { return b } +func translateLegacyValueForKey(newKey, value []byte) []byte { + if len(newKey) == 0 || value == nil { + return value + } + + switch newKey[0] { + case 0x01: + return translateLegacyCodeInfoValue(value) + case 0x02: + return translateLegacyContractInfoValue(value) + default: + return value + } +} + +func translateLegacyCodeInfoValue(value []byte) []byte { + var legacyInfo legacytypes.LegacyCodeInfo + if err := legacyInfo.Unmarshal(value); err != nil { + return value + } + + translated := wasmtypes.CodeInfo{ + CodeHash: append([]byte(nil), legacyInfo.CodeHash...), + Creator: legacyInfo.Creator, + } + marshaled, err := translated.Marshal() + if err != nil { + return value + } + return marshaled +} + +func translateLegacyContractInfoValue(value []byte) []byte { + var legacyInfo legacytypes.LegacyContractInfo + if err := legacyInfo.Unmarshal(value); err != nil { + return value + } + + translated := wasmtypes.ContractInfo{ + CodeID: legacyInfo.CodeID, + Creator: legacyInfo.Creator, + Admin: legacyInfo.Admin, + } + marshaled, err := translated.Marshal() + if err != nil { + return value + } + return marshaled +} + func (s *legacyWasmStore) Get(key []byte) []byte { for _, cand := range translateNewToOld(key) { if bz := s.parent.Get(cand); bz != nil { - return bz + return translateLegacyValueForKey(key, bz) } } return nil @@ -351,7 +403,7 @@ func (it *legacyIterator) advance() { continue } it.key = newKey - it.val = it.under.Value() + it.val = translateLegacyValueForKey(newKey, it.under.Value()) it.valid = true it.under.Next() // Advance before returning, since post-statement won't run return diff --git a/custom/wasm/query_handler_test.go b/custom/wasm/query_handler_test.go index c23d29fee..92ac8ed3f 100644 --- a/custom/wasm/query_handler_test.go +++ b/custom/wasm/query_handler_test.go @@ -3,8 +3,10 @@ package wasm import ( "testing" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + legacytypes "github.com/classic-terra/core/v3/custom/wasm/types/legacy" coretypes "github.com/classic-terra/core/v3/types" dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" @@ -449,6 +451,91 @@ func (suite *LegacyQueryHandlerTestSuite) TestHandleQuery_LegacyStoreIntegration }) } +func (suite *LegacyQueryHandlerTestSuite) TestLegacyStore_TranslatesLegacyMetadataValues() { + ctx := suite.ctx.WithChainID(coretypes.ColumbusChainID).WithBlockHeight(25619229) + parent := ctx.KVStore(suite.storeKey) + legacyStore := &legacyWasmStore{parent: parent} + + contractAddr := make([]byte, 20) + for i := range contractAddr { + contractAddr[i] = byte(i + 1) + } + codeID := uint64(77) + + oldContractKey := append([]byte{0x04, 0x14}, contractAddr...) + oldContractValue, err := (&legacytypes.LegacyContractInfo{ + Address: "terra1legacycontract", + Creator: "terra1creator", + Admin: "terra1admin", + CodeID: codeID, + InitMsg: []byte(`{"count":1}`), + }).Marshal() + require.NoError(suite.T(), err) + parent.Set(oldContractKey, oldContractValue) + + oldCodeKey := append([]byte{0x03}, sdk.Uint64ToBigEndian(codeID)...) + oldCodeValue, err := (&legacytypes.LegacyCodeInfo{ + CodeID: codeID, + CodeHash: []byte("legacy-hash"), + Creator: "terra1creator", + }).Marshal() + require.NoError(suite.T(), err) + parent.Set(oldCodeKey, oldCodeValue) + + newContractKey := append([]byte{0x02}, contractAddr...) + contractBz := legacyStore.Get(newContractKey) + require.NotNil(suite.T(), contractBz) + + var contractInfo wasmtypes.ContractInfo + require.NoError(suite.T(), contractInfo.Unmarshal(contractBz)) + require.Equal(suite.T(), codeID, contractInfo.CodeID) + require.Equal(suite.T(), "terra1creator", contractInfo.Creator) + require.Equal(suite.T(), "terra1admin", contractInfo.Admin) + require.Empty(suite.T(), contractInfo.Label) + + newCodeKey := append([]byte{0x01}, sdk.Uint64ToBigEndian(codeID)...) + codeBz := legacyStore.Get(newCodeKey) + require.NotNil(suite.T(), codeBz) + + var codeInfo wasmtypes.CodeInfo + require.NoError(suite.T(), codeInfo.Unmarshal(codeBz)) + require.Equal(suite.T(), []byte("legacy-hash"), codeInfo.CodeHash) + require.Equal(suite.T(), "terra1creator", codeInfo.Creator) +} + +func (suite *LegacyQueryHandlerTestSuite) TestLegacyStore_IteratorTranslatesLegacyMetadataValues() { + ctx := suite.ctx.WithChainID(coretypes.ColumbusChainID).WithBlockHeight(25619229) + parent := ctx.KVStore(suite.storeKey) + legacyStore := &legacyWasmStore{parent: parent} + + contractAddr := make([]byte, 20) + for i := range contractAddr { + contractAddr[i] = byte(20 - i) + } + + oldContractKey := append([]byte{0x04, 0x14}, contractAddr...) + oldContractValue, err := (&legacytypes.LegacyContractInfo{ + Address: "terra1legacycontract", + Creator: "terra1creator", + CodeID: 9, + }).Marshal() + require.NoError(suite.T(), err) + parent.Set(oldContractKey, oldContractValue) + + iter := legacyStore.Iterator([]byte{0x02}, []byte{0x03}) + defer iter.Close() + + require.True(suite.T(), iter.Valid()) + require.Equal(suite.T(), append([]byte{0x02}, contractAddr...), iter.Key()) + + var contractInfo wasmtypes.ContractInfo + require.NoError(suite.T(), contractInfo.Unmarshal(iter.Value())) + require.Equal(suite.T(), uint64(9), contractInfo.CodeID) + require.Equal(suite.T(), "terra1creator", contractInfo.Creator) + iter.Next() + require.False(suite.T(), iter.Valid()) +} + // Test the isPreWasmKeyMigration function directly func (suite *LegacyQueryHandlerTestSuite) TestIsPreWasmKeyMigration() { testCases := []struct { From ff6a0cd9fe1559261a4403aeb1cbea453956bc7f Mon Sep 17 00:00:00 2001 From: StrathCole Date: Tue, 17 Mar 2026 06:31:01 +0100 Subject: [PATCH 3/3] - lint --- custom/wasm/query_handler_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/wasm/query_handler_test.go b/custom/wasm/query_handler_test.go index 92ac8ed3f..c10ffc764 100644 --- a/custom/wasm/query_handler_test.go +++ b/custom/wasm/query_handler_test.go @@ -3,8 +3,8 @@ package wasm import ( "testing" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmvmtypes "github.com/CosmWasm/wasmvm/types" legacytypes "github.com/classic-terra/core/v3/custom/wasm/types/legacy" coretypes "github.com/classic-terra/core/v3/types"