Skip to content

Migrate old dex prefix data#491

Merged
LCyson merged 1 commit intomasterfrom
dex-migration
Jan 20, 2023
Merged

Migrate old dex prefix data#491
LCyson merged 1 commit intomasterfrom
dex-migration

Conversation

@LCyson
Copy link
Contributor

@LCyson LCyson commented Jan 19, 2023

Describe your changes and provide context

This PR adds a migration handler for the dex prefixes change here: #483. To be noted that here we will simply nuke the old data as this will only be needed on the devnet-2.

Other option is to replace the existing data like the snippet below, but given there are keys with suffix, either getting all pairs from contracts or assuming the contract address length is 62 in bytes is not as safe as nuking the old data on the devnet-2.


	for _, prefixKey := range DexPrefixes {
		store := prefix.NewStore(ctx.KVStore(dexkeeper.GetStoreKey()), []byte(prefixKey))
		iterator := sdk.KVStorePrefixIterator(store, []byte{})

		defer iterator.Close()
		for ; iterator.Valid(); iterator.Next() {
			key := iterator.Key()
			if !bytes.HasPrefix(key, []byte(prefixKey)) {
				panic(fmt.Sprintf("Key %x doesn't has prefix %s\n", key, prefixKey))
			}
			key = bytes.TrimPrefix(key, []byte(prefixKey))

			key = append([]byte(prefixKey), types.AddressKeyPrefix(string(key))...)

			store.Set(key, iterator.Value())
			store.Delete(iterator.Key())
		}
	}

Testing performed to validate your change

  • Unit test
  • Upgraded the chain locally with the following steps
    • deployed vortex contract to V10
    • placed an order
    • upgraded to V11
    • confirmed the order is nuked and no panic/exception was thrown

@github-actions
Copy link

Code Coverage

Package Line Rate Complexity Health
github.com/sei-protocol/sei-chain/aclmapping/bank 83% 0
github.com/sei-protocol/sei-chain/aclmapping/dex 100% 0
github.com/sei-protocol/sei-chain/aclmapping/oracle 100% 0
github.com/sei-protocol/sei-chain/aclmapping/staking 82% 0
github.com/sei-protocol/sei-chain/aclmapping/tokenfactory 96% 0
github.com/sei-protocol/sei-chain/aclmapping/utils 0% 0
github.com/sei-protocol/sei-chain/aclmapping/wasm 83% 0
github.com/sei-protocol/sei-chain/app 59% 0
github.com/sei-protocol/sei-chain/app/antedecorators 75% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/config 85% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle 73% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle/provider 48% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/router/v1 45% 0
github.com/sei-protocol/sei-chain/store/whitelist/cachemulti 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/kv 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/multi 100% 0
github.com/sei-protocol/sei-chain/utils 46% 0
github.com/sei-protocol/sei-chain/utils/datastructures 90% 0
github.com/sei-protocol/sei-chain/x/dex 58% 0
github.com/sei-protocol/sei-chain/x/dex/cache 86% 0
github.com/sei-protocol/sei-chain/x/dex/client/cli/query 23% 0
github.com/sei-protocol/sei-chain/x/dex/contract 53% 0
github.com/sei-protocol/sei-chain/x/dex/exchange 89% 0
github.com/sei-protocol/sei-chain/x/dex/keeper 67% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/abci 29% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/msgserver 77% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/query 82% 0
github.com/sei-protocol/sei-chain/x/dex/migrations 88% 0
github.com/sei-protocol/sei-chain/x/dex/types 1% 0
github.com/sei-protocol/sei-chain/x/dex/types/utils 100% 0
github.com/sei-protocol/sei-chain/x/dex/types/wasm 83% 0
github.com/sei-protocol/sei-chain/x/epoch 11% 0
github.com/sei-protocol/sei-chain/x/epoch/keeper 66% 0
github.com/sei-protocol/sei-chain/x/epoch/types 2% 0
github.com/sei-protocol/sei-chain/x/mint 0% 0
github.com/sei-protocol/sei-chain/x/mint/keeper 75% 0
github.com/sei-protocol/sei-chain/x/mint/simulation 95% 0
github.com/sei-protocol/sei-chain/x/mint/types 2% 0
github.com/sei-protocol/sei-chain/x/nitro/client/cli 45% 0
github.com/sei-protocol/sei-chain/x/nitro/keeper 80% 0
github.com/sei-protocol/sei-chain/x/nitro/replay 63% 0
github.com/sei-protocol/sei-chain/x/oracle 64% 0
github.com/sei-protocol/sei-chain/x/oracle/keeper 82% 0
github.com/sei-protocol/sei-chain/x/oracle/simulation 18% 0
github.com/sei-protocol/sei-chain/x/oracle/types 3% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/keeper 85% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/types 2% 0
Summary 15% (5034 / 33941) 0

Copy link
Contributor

@philipsu522 philipsu522 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but let's get @codchen 's reviews as well.
in your local test, was vortex contract deployed with data on it (long book, orders...etc.)

@LCyson
Copy link
Contributor Author

LCyson commented Jan 19, 2023

lgtm, but let's get @codchen 's reviews as well. in your local test, was vortex contract deployed with data on it (long book, orders...etc.)

Yes, tested by placing a LONG order and verified that order and also the trading pairs are nuked

@LCyson LCyson merged commit ffa5605 into master Jan 20, 2023
masih pushed a commit that referenced this pull request Sep 29, 2025
This reverts commit e2825c2.

## Describe your changes and provide context
We disable cachekv events for `v0.3.xx+` versions because those are used
in sei chain without allowing for parallelV1 concurrency due to its
incompatibility with EVM

## Testing performed to validate your change
masih pushed a commit that referenced this pull request Sep 30, 2025
This reverts commit e2825c2.

## Describe your changes and provide context
We disable cachekv events for `v0.3.xx+` versions because those are used
in sei chain without allowing for parallelV1 concurrency due to its
incompatibility with EVM

## Testing performed to validate your change
@masih masih deleted the dex-migration branch October 31, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants