-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
go func() { | ||
err = types.ValidateGenesisStream(genesisStateCh) | ||
doneCh <- struct{}{} | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
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
x/wasm/keeper/genesis.go
Outdated
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
No description provided.