You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide an alternative to AppGenesisFromFile which does not depend on a file lookup to create an instance of AppGenesis.
Problem Definition
In the ibc-go e2e tests, we use interchain test which provides a hook to modify the genesis bytes. In order to provide modifications, we need to serialize the bytes, make changes, and return the new bytes.
The current implementation of AppGenesisFromFile does a direct os.ReadFile and so is not quite flexible enough to meet our use case.
Proposed Feature
I propose the method signature is changed (or a new fn is added is the original behaviour is still required!)
I think using an io.Reader is a nice ux for this.
// AppGenesisFromReader reads the AppGenesis from the reader.funcAppGenesisFromReader(reader io.Reader) (*AppGenesis, error) {
jsonBlob, err:=io.ReadAll(reader)
iferr!=nil {
returnnil, err
}
varappGenesisAppGenesisiferr:=json.Unmarshal(jsonBlob, &appGenesis); err!=nil {
// fallback to CometBFT genesisvarctmGenesis cmttypes.GenesisDociferr2:=cmtjson.Unmarshal(jsonBlob, &ctmGenesis); err2!=nil {
returnnil, fmt.Errorf("error unmarshalling AppGenesis: %w\n failed fallback to CometBFT GenDoc: %w", err, err2)
}
appGenesis=AppGenesis{
AppName: version.AppName,
// AppVersion is not filled as we do not know it from a CometBFT genesisGenesisTime: ctmGenesis.GenesisTime,
ChainID: ctmGenesis.ChainID,
InitialHeight: ctmGenesis.InitialHeight,
AppHash: ctmGenesis.AppHash,
AppState: ctmGenesis.AppState,
Consensus: &ConsensusGenesis{
Validators: ctmGenesis.Validators,
Params: ctmGenesis.ConsensusParams,
},
}
}
return&appGenesis, nil
}
// AppGenesisFromFile reads the AppGenesis from the provided file.funcAppGenesisFromFile(genFilestring) (*AppGenesis, error) {
file, err:=os.Open(genFile)
iferr!=nil {
returnnil, err
}
returnAppGenesisFromReader(bufio.NewReader(file))
}
The text was updated successfully, but these errors were encountered:
Summary
Provide an alternative to
AppGenesisFromFile
which does not depend on a file lookup to create an instance ofAppGenesis
.Problem Definition
In the ibc-go e2e tests, we use interchain test which provides a hook to modify the genesis bytes. In order to provide modifications, we need to serialize the bytes, make changes, and return the new bytes.
The current implementation of
AppGenesisFromFile
does a directos.ReadFile
and so is not quite flexible enough to meet our use case.Proposed Feature
I propose the method signature is changed (or a new fn is added is the original behaviour is still required!)
I think using an
io.Reader
is a nice ux for this.The text was updated successfully, but these errors were encountered: