Closed odeke-em closed 3 weeks ago
want to make a pr?
want to make a pr?
Hi, I'm interested in picking up this issue, would it just involve making the changes to x/genutil/types/genesis.go
as described above?
want to make a pr?
Hi, I'm interested in picking up this issue, would it just involve making the changes to
x/genutil/types/genesis.go
as described above?
Essentially yes, thank you!
Is there an existing issue for this?
What happened?
While auditing cometbft to evaluate how we can use an incremental JSON parser instead of always invoking cometbft/libs/json.Unmarshal(bytes...) which requires reading an entire Genesis file into RAM, I noticed this code https://github.com/cosmos/cosmos-sdk/blob/430b53236ef6fb775fe1eb753c0154b17ba419ac/x/genutil/types/genesis.go#L91-L101
The need to invoke cmtjson.Unmarshal as an alternative seems to pigeonhole the need to slurp in all the bytes
Unnecessary invocation of bufio.NewReader
This code is unnecessary to pass in
bufio.NewReader(*os.File)
yet immediately just invokingio.ReadAll
, to read the entire file into RAMPrognosis
These problems are from pigeon holing and over-generalizations because: a) The use of AppGenesisFromFile is in server/start.go and it opens an
*os.File
which implements io.ReadSeekCloser which can help us in the case that the encoding/json parsing would work and perhaps not having known about io.ReadSeeker might have constrained the thinking and implementation but even bytes.NewReader implementsCosmos SDK Version
main
How to reproduce?
Please see my detailed report.
/cc @elias-orijtech @ValarDragon