Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;
lazy_static::lazy_static! {
/// Current hardcoded contract admins
static ref HARDCODED_CONTRACT_ADMINS: HashMap<&'static str, &'static str> = HashMap::from([
("secret1hg83qtpn0444k7shhmuawhykklycd7qt24z34g", "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms"), // snip20 testnet contract
("secret1vuq7hw2qp5trqyp4vzm6axpg4jrw6vc03uzgrp", "secret1pcegd258whwdynv76xtudwhshq3dv73rwjx5jf"), // snip20 testnet contract
("secret1jr05klxup5285wv2w24x3rs6rr37c8fyz39evd", "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms"), // snip20 testnet contract
("secret1my2ycry070nsgugw67k4ej93ttsgut5yd8xnhj", "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms"), // snip20 testnet contract
("secret1rekrj69d9kl7p5gpcq7d0qrwdrw0hmszrv5hy3", "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms"), // snip20 testnet contract
Expand Down Expand Up @@ -581,6 +581,7 @@ lazy_static::lazy_static! {
("secret16snu3lt8k9u0xr54j2hqyhvwnx9my7kq7ay8lp", "secret1hxrvx0v0zvqgmpuzspdg5j8rrxpjgyjql3w9gh"), // ERTH
("secret14p6dhjznntlzw0yysl7p6z069nk0skv5e9qjut", "secret1hxrvx0v0zvqgmpuzspdg5j8rrxpjgyjql3w9gh"), // ANML
("secret1yrzp33hvkwd3dr5farjgwdutecrhd0r7uhqksq", "secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03"), // testnet contract
("secret1r2vzslwkad9vcg06hgy4km9zh4jvawxtc2hl98", "secret16cx295surhm7ps60jsfwernx4kxa4gf8z7yxvd"), // derivative_hooks
]);

/// The entire history of contracts that were deployed before v1.10 and have been migrated using the hardcoded admin feature.
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ replace (
cosmossdk.io/api => github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0
cosmossdk.io/store => github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1
cosmossdk.io/x/tx => github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0
github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.19-secret.11
github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.14-secret.10
github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.23-secret.0
github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.14-secret.11
github.com/cosmos/iavl => github.com/scrtlabs/iavl v1.2.2-secret.0
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

Expand Down Expand Up @@ -175,13 +175,13 @@ require (
github.com/klauspost/compress v1.17.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lib/pq v1.12.0 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/highwayhash v1.0.3 // indirect
github.com/minio/highwayhash v1.0.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -190,7 +190,7 @@ require (
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.21.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
Expand All @@ -201,7 +201,7 @@ require (
github.com/rs/cors v1.11.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.5 // indirect
github.com/sasha-s/go-deadlock v0.3.9 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,8 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.12.0 h1:mC1zeiNamwKBecjHarAr26c/+d8V5w/u4J0I/yASbJo=
github.com/lib/pq v1.12.0/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ=
Expand Down Expand Up @@ -1435,8 +1435,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75 h1:cUVxyR+UfmdEAZGJ8IiKld1O0dbGotEnkMolG5hfMSY=
github.com/miscreant/miscreant.go v0.0.0-20200214223636-26d376326b75/go.mod h1:pBbZyGwC5i16IBkjVKoy/sznA8jPD/K9iedwe1ESE6w=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
Expand Down Expand Up @@ -1521,8 +1521,8 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw=
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe h1:vHpqOnPlnkba8iSxU4j/CvDSS9J4+F4473esQsYLGoE=
github.com/petermattis/goid v0.0.0-20250813065127-a731cc31b4fe/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
Expand Down Expand Up @@ -1607,10 +1607,10 @@ github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgY
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU=
github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U=
github.com/scrtlabs/cosmos-sdk v0.50.14-secret.10 h1:MJgXkosWs87TCy76l0cbxDUL4/7xlO1fKdFYPGKUkYM=
github.com/scrtlabs/cosmos-sdk v0.50.14-secret.10/go.mod h1:czzdPa3SiwDgWM0QqTZLKgwaF9k5w3rMS1kJzHIoGbQ=
github.com/sasha-s/go-deadlock v0.3.9 h1:fiaT9rB7g5sr5ddNZvlwheclN9IP86eFW9WgqlEQV+w=
github.com/sasha-s/go-deadlock v0.3.9/go.mod h1:KuZj51ZFmx42q/mPaYbRk0P1xcwe697zsJKE03vD4/Y=
github.com/scrtlabs/cosmos-sdk v0.50.14-secret.11 h1:Yl1x19k6jIFXPDX/Rrj1p4z7EsQDVhNJt0gX1/JuJsM=
github.com/scrtlabs/cosmos-sdk v0.50.14-secret.11/go.mod h1:b7GmzR/8Ic9g6Aswsm3ryLhE5dhgbKTJ6o78mhxjRO4=
github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0 h1:9IGLySVhC2qSrxT3fZvvqwjKsnXWSSKnywQDzT8y1Gs=
github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1 h1:TELtwBkSg0xBrs2ObFE0pVVWF6E31fPCDX2tk8OiJPo=
Expand All @@ -1619,8 +1619,8 @@ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 h1:i3k5706sDHKhaCvzokB+n33/
github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/scrtlabs/iavl v1.2.2-secret.0 h1:P96PL1Lf8OBSW9pMrlaRxhceZ4z9Hc7jk12g9ShWeHw=
github.com/scrtlabs/iavl v1.2.2-secret.0/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw=
github.com/scrtlabs/tendermint v0.38.19-secret.11 h1:WeIDyA3Svm3fYdp2cRr2U2IE9Q9TYNODTS4Nzifp+xY=
github.com/scrtlabs/tendermint v0.38.19-secret.11/go.mod h1:I8kyAQPjMco6jjCshUSMYFoY6TybsbADGBmGcjWrgKM=
github.com/scrtlabs/tendermint v0.38.23-secret.0 h1:nPt77SkQILJR6skCIZJclcTtjnHeU6wrqzvVqg3hAps=
github.com/scrtlabs/tendermint v0.38.23-secret.0/go.mod h1:HHgYHxYnGRCJIqihEbfO+icKitZUiYOKE529pQRIEu4=
github.com/scrtlabs/tm-secret-enclave v1.13.1 h1:0mXcBdoWyqEGhQEdbXMjSuTi9LKKMld2BqEj0eNpoxU=
github.com/scrtlabs/tm-secret-enclave v1.13.1/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
Expand Down
3 changes: 2 additions & 1 deletion x/compute/internal/keeper/hardcoded_admins.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper
// This map enables these gov-proposed contracts to have admin functionality even though they
// were created before the contract upgrade feature existed
var hardcodedContractAdmins = map[string]string{
"secret1hg83qtpn0444k7shhmuawhykklycd7qt24z34g": "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms", // snip20 testnet contract
"secret1vuq7hw2qp5trqyp4vzm6axpg4jrw6vc03uzgrp": "secret1pcegd258whwdynv76xtudwhshq3dv73rwjx5jf", // snip20 testnet contract
"secret1jr05klxup5285wv2w24x3rs6rr37c8fyz39evd": "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms", // snip20 testnet contract
"secret1my2ycry070nsgugw67k4ej93ttsgut5yd8xnhj": "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms", // snip20 testnet contract
"secret1rekrj69d9kl7p5gpcq7d0qrwdrw0hmszrv5hy3": "secret1f2jrcqsx7glyta39c6tum2lhk5kh2a0ty6r9ms", // snip20 testnet contract
Expand Down Expand Up @@ -579,4 +579,5 @@ var hardcodedContractAdmins = map[string]string{
"secret16snu3lt8k9u0xr54j2hqyhvwnx9my7kq7ay8lp": "secret1hxrvx0v0zvqgmpuzspdg5j8rrxpjgyjql3w9gh",
"secret14p6dhjznntlzw0yysl7p6z069nk0skv5e9qjut": "secret1hxrvx0v0zvqgmpuzspdg5j8rrxpjgyjql3w9gh",
"secret1yrzp33hvkwd3dr5farjgwdutecrhd0r7uhqksq": "secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03",
"secret1r2vzslwkad9vcg06hgy4km9zh4jvawxtc2hl98": "secret16cx295surhm7ps60jsfwernx4kxa4gf8z7yxvd", // derivative_hooks
}
36 changes: 36 additions & 0 deletions x/compute/internal/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,42 @@
return nil
}

// Migrate8to9 migrates from version 8 to 9. The migration includes setting the admin for any newly added hardcoded contracts
func (m Migrator) Migrate8to9(ctx sdk.Context) error {
store := prefix.NewStore(runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)), types.ContractKeyPrefix)

// Iterate only over the hardcoded list
for contractAddrStr, newAdmin := range hardcodedContractAdmins {
if newAdmin == "" {
continue
}

contractAddress, err := sdk.AccAddressFromBech32(contractAddrStr)
if err != nil {
ctx.Logger().Error("Migrate8to9: invalid contract address in hardcoded admins", "contract", contractAddrStr, "error", err)
continue
}

bz := store.Get(contractAddress)
if bz != nil {
var contractInfo types.ContractInfo
m.keeper.cdc.MustUnmarshal(bz, &contractInfo)

if newAdmin != contractInfo.Admin {
contractInfo.Admin = newAdmin
contractInfo.AdminProof = make([]byte, 32) // Dummy proof, ignored by enclave

updatedBz := m.keeper.cdc.MustMarshal(&contractInfo)
store.Set(contractAddress, updatedBz)

ctx.Logger().Info("Migrate8to9: successfully migrated admin for contract", "contract", contractAddrStr, "new_admin", newAdmin)
}
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +221 to +247

return nil
}

const progressPartSize = 1000

func logMigrationProgress(ctx sdk.Context, formatter *message.Printer, migratedContracts uint64, totalContracts uint64, previousTime int64) {
Expand Down
7 changes: 6 additions & 1 deletion x/compute/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewAppModule(keeper Keeper) AppModule {
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 8 }
func (AppModule) ConsensusVersion() uint64 { return 9 }

func (am AppModule) RegisterServices(configurator module.Configurator) {
types.RegisterMsgServer(configurator.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
Expand Down Expand Up @@ -133,6 +133,11 @@ func (am AppModule) RegisterServices(configurator module.Configurator) {
if err != nil {
panic(err)
}

err = configurator.RegisterMigration(types.ModuleName, 8, m.Migrate8to9)
if err != nil {
panic(err)
}
}

// InitGenesis performs genesis initialization for the compute module. It returns
Expand Down
Loading