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

Genesis export OOM #58

Merged
merged 17 commits into from
Jul 29, 2024
Merged

Genesis export OOM #58

merged 17 commits into from
Jul 29, 2024

Conversation

jewei1997
Copy link
Contributor

No description provided.

x/wasm/keeper/genesis.go Fixed Show fixed Hide fixed
Comment on lines +85 to +88
go func() {
err = types.ValidateGenesisStream(genesisStateCh)
doneCh <- struct{}{}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
Comment on lines +89 to +101
go func() {
defer close(genesisStateCh)
for genesis := range genesisCh {
var data GenesisState
err_ := cdc.UnmarshalJSON(genesis, &data)
if err_ != nil {
err = err_
doneCh <- struct{}{}
return
}
genesisStateCh <- data
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
x/wasm/module.go Dismissed Show dismissed Hide dismissed
Comment on lines 142 to 209
go func() {
var genState types.GenesisState
genState.Params = keeper.GetParams(ctx)
ch <- &genState

// Needs to be first because there are invariant checks when importing that need sequences info
for _, k := range [][]byte{types.KeyLastCodeID, types.KeyLastInstanceID} {
var genState types.GenesisState
genState.Params = keeper.GetParams(ctx)
genState.Sequences = append(genState.Sequences, types.Sequence{
IDKey: k,
Value: keeper.PeekAutoIncrementID(ctx, k),
})
ch <- &genState
}

keeper.IterateCodeInfos(ctx, func(codeID uint64, info types.CodeInfo) bool {
var genState types.GenesisState
genState.Params = keeper.GetParams(ctx)
bytecode, err := keeper.GetByteCode(ctx, codeID)
if err != nil {
panic(err)
}
genState.Codes = append(genState.Codes, types.Code{
CodeID: codeID,
CodeInfo: info,
CodeBytes: bytecode,
Pinned: keeper.IsPinnedCode(ctx, codeID),
})
ch <- &genState
return false
})

fmt.Println("About to IterateContractInfo")
keeper.IterateContractInfo(ctx, func(addr sdk.AccAddress, contract types.ContractInfo) bool {
// redact contract info
contract.Created = nil
var state []types.Model
keeper.IterateContractState(ctx, addr, func(key, value []byte) bool {
state = append(state, types.Model{Key: key, Value: value})
if len(state) > GENSIS_STATE_STREAM_BUF_THRESHOLD {
var genState types.GenesisState
genState.Params = keeper.GetParams(ctx)
genState.Contracts = append(genState.Contracts, types.Contract{
ContractAddress: addr.String(),
ContractInfo: contract,
ContractState: state,
})
ch <- &genState
state = nil
}
return false
})
// flush any remaining state
var genState types.GenesisState
genState.Params = keeper.GetParams(ctx)
genState.Contracts = append(genState.Contracts, types.Contract{
ContractAddress: addr.String(),
ContractInfo: contract,
ContractState: state,
})
ch <- &genState
return false
})
fmt.Println("Done with IterateContractInfo")

close(ch)
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
x/wasm/keeper/keeper.go Outdated Show resolved Hide resolved
x/wasm/keeper/keeper.go Outdated Show resolved Hide resolved
@jewei1997 jewei1997 merged commit 42f56f7 into main Jul 29, 2024
2 checks passed
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.

3 participants