Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V6.0.0 debug #1964

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion app/test_state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *InMemoryStateStore) GetEarliestVersion() (int64, error) {
return s.earliestVersion, nil
}

func (s *InMemoryStateStore) SetEarliestVersion(version int64) error {
func (s *InMemoryStateStore) SetEarliestVersion(version int64, ignoreVersion bool) error {
s.mu.Lock()
defer s.mu.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion app/test_state_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestGetLatestVersionAndSetLatestVersion(t *testing.T) {
func TestGetEarliestVersionAndSetEarliestVersion(t *testing.T) {
store := NewInMemoryStateStore()

err := store.SetEarliestVersion(1)
err := store.SetEarliestVersion(1, false)
assert.NoError(t, err)

version, err := store.GetEarliestVersion()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ require (
replace (
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.44
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.45-0.20241126071749-02884fc09b82
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-23
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.45
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.46-0.20241126071112-885e77fbd9e6
// Latest goleveldb is broken, we have to stick to this version
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.4.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1347,10 +1347,10 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-23 h1:rkgeOHC56QTco4mIyGd6cZHtlo
github.com/sei-protocol/go-ethereum v1.13.5-sei-23/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.3.44 h1:7wLuJguQBhQ1ljU92lEDrZDLcNt+JbUcX7r1Y7V1qws=
github.com/sei-protocol/sei-cosmos v0.3.44/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk=
github.com/sei-protocol/sei-db v0.0.45 h1:95ygzGFMyvaGwEUmzlKi8MxwXfbluoNzbaIjy9zOG6o=
github.com/sei-protocol/sei-db v0.0.45/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA=
github.com/sei-protocol/sei-cosmos v0.3.45-0.20241126071749-02884fc09b82 h1:Esxuei2l2CHLX/VB4Rb6/25/ab6RISX7PcDGqxOR2jk=
github.com/sei-protocol/sei-cosmos v0.3.45-0.20241126071749-02884fc09b82/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk=
github.com/sei-protocol/sei-db v0.0.46-0.20241126071112-885e77fbd9e6 h1:aos5eaDcoTk5nBcsS2A5hO/mhgdUrGGoBQfPMLfCfaI=
github.com/sei-protocol/sei-db v0.0.46-0.20241126071112-885e77fbd9e6/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA=
github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I=
github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 h1:BaMZ6gjwqe3R/5dLmcJ1TkSZ3omcWy2TjaAZAeOJH44=
Expand Down
1 change: 1 addition & 0 deletions tools/migration/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func verify(cmd *cobra.Command, _ []string) {

func verifySS(version int64, homeDir string, db dbm.DB) error {
ssConfig := config.DefaultStateStoreConfig()
ssConfig.KeepRecent = 0
ssConfig.Enable = true

stateStore, err := sstypes.NewStateStore(log.NewNopLogger(), homeDir, ssConfig)
Expand Down
52 changes: 42 additions & 10 deletions tools/migration/ss/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (

var modules = []string{
"wasm", "aclaccesscontrol", "oracle", "epoch", "mint", "acc", "bank", "feegrant", "staking", "distribution", "slashing", "gov", "params", "ibc", "upgrade", "evidence", "transfer", "tokenfactory",
"evm", "capability", "authz",
}

func NewMigrator(homeDir string, db dbm.DB, stateStore types.StateStore) *Migrator {
Expand All @@ -47,17 +48,21 @@ func (m *Migrator) Migrate(version int64, homeDir string) error {
return fmt.Errorf("failed to get latest module: %w", err)
}

fmt.Println("Starting migration...")
fmt.Println("SeiDB Archive Migration: Starting migration...")

// Goroutine to iterate through IAVL and export leaf nodes
go func() {
defer close(ch)
errCh <- ExportLeafNodesFromKey(m.iavlDB, ch, latestKey, latestModule)
err := ExportLeafNodesFromKey(m.iavlDB, ch, latestKey, latestModule)
errCh <- err
fmt.Printf("SeiDB Archive Migration: ExportLeafNodesFromKey Finished with err %+v \n", err)
}()

// Import nodes into PebbleDB
go func() {
errCh <- m.stateStore.RawImport(ch)
err := m.stateStore.RawImport(ch)
errCh <- err
fmt.Printf("SeiDB Archive Migration: RawImport Finished with err %+v \n", err)
}()

// Block until both processes complete
Expand All @@ -67,17 +72,40 @@ func (m *Migrator) Migrate(version int64, homeDir string) error {
}
}

// Set earliest and latest version in the database
err = m.stateStore.SetEarliestVersion(1)
if err != nil {
return err
}
fmt.Println("SeiDB Archive Migration: Setting earliest version")

return m.stateStore.SetLatestVersion(version)
// Set earliest version in the database
return m.stateStore.SetEarliestVersion(1, true)
}

func (m *Migrator) Verify(version int64) error {
var verifyErr error
earliestVersion, err := m.stateStore.GetEarliestVersion()
if err != nil {
fmt.Println("Could not retrieve earliest version from state store")
return err
}
latestVersion, err := m.stateStore.GetLatestVersion()
if err != nil {
fmt.Println("Could not retrieve latest version from state store")
return err
}
latestMigratedModule, err := m.stateStore.GetLatestMigratedModule()
fmt.Printf("State Store earliest version: %d latest version: %d latestModule %s.\n", earliestVersion, latestVersion, latestMigratedModule)

err = m.stateStore.SetEarliestVersion(1, true)
if err != nil {
return err
}

earliestVersion, err = m.stateStore.GetEarliestVersion()
if err != nil {
fmt.Println("Could not retrieve earliest version from state store")
return err
}

fmt.Printf("State Store earliest version after set: %d latest version: %d latestModule %s.\n", earliestVersion, latestVersion, latestMigratedModule)

for _, module := range modules {
tree, err := ReadTree(m.iavlDB, version, []byte(buildTreePrefix(module)))
if err != nil {
Expand Down Expand Up @@ -110,9 +138,13 @@ func (m *Migrator) Verify(version int64) error {
fmt.Printf("SeiDB Archive Migration: Failed to iterate the tree %s: %s\n", module, err.Error())
return err
}
if verifyErr != nil {
return verifyErr
}
fmt.Printf("SeiDB Archive Migration:: Finished verifying module %s, total scanned: %d keys\n", module, count)
}
return verifyErr

return nil
}

func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey []byte, startModule string) error {
Expand Down