Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/gh-bo…
Browse files Browse the repository at this point in the history
…t-reviewer
  • Loading branch information
thehowl committed Feb 7, 2025
2 parents ada08b5 + be61d7d commit 681dea2
Show file tree
Hide file tree
Showing 23 changed files with 91 additions and 34 deletions.
1 change: 1 addition & 0 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnofaucet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require (
github.com/rs/cors v1.11.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnofaucet/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnogenesis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.11 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnogenesis/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnohealth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnohealth/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contribs/gnomigrate/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ require (
github.com/rs/xid v1.6.0 // indirect
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.etcd.io/bbolt v1.3.11 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions contribs/gnomigrate/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b
github.com/stretchr/testify v1.10.0
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/valyala/bytebufferpool v1.0.0
github.com/yuin/goldmark v1.7.8
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
go.etcd.io/bbolt v1.3.11
Expand Down
2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions misc/autocounterd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions misc/autocounterd/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions misc/loop/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ require (
github.com/sig-0/insertion-queue v0.0.0-20241004125609-6b3ca841346b // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.etcd.io/bbolt v1.3.11 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions misc/loop/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 31 additions & 17 deletions tm2/pkg/amino/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ func (cdc *Codec) MarshalSized(o interface{}) ([]byte, error) {
cdc.doAutoseal()

// Write the bytes here.
buf := new(bytes.Buffer)
buf := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(buf)

// Write the bz without length-prefixing.
bz, err := cdc.Marshal(o)
Expand All @@ -239,7 +240,7 @@ func (cdc *Codec) MarshalSized(o interface{}) ([]byte, error) {
return nil, err
}

return buf.Bytes(), nil
return copyBytes(buf.Bytes()), nil
}

// MarshalSizedWriter writes the bytes as would be returned from
Expand Down Expand Up @@ -271,8 +272,8 @@ func (cdc *Codec) MarshalAnySized(o interface{}) ([]byte, error) {
cdc.doAutoseal()

// Write the bytes here.
buf := new(bytes.Buffer)

buf := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(buf)
// Write the bz without length-prefixing.
bz, err := cdc.MarshalAny(o)
if err != nil {
Expand All @@ -291,7 +292,7 @@ func (cdc *Codec) MarshalAnySized(o interface{}) ([]byte, error) {
return nil, err
}

return buf.Bytes(), nil
return copyBytes(buf.Bytes()), nil
}

func (cdc *Codec) MustMarshalAnySized(o interface{}) []byte {
Expand Down Expand Up @@ -357,7 +358,9 @@ func (cdc *Codec) MarshalReflect(o interface{}) ([]byte, error) {

// Encode Amino:binary bytes.
var bz []byte
buf := new(bytes.Buffer)
buf := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(buf)

rt := rv.Type()
info, err := cdc.getTypeInfoWLock(rt)
if err != nil {
Expand All @@ -377,7 +380,7 @@ func (cdc *Codec) MarshalReflect(o interface{}) ([]byte, error) {
if err = cdc.writeFieldIfNotEmpty(buf, 1, info, FieldOptions{}, FieldOptions{}, rv, writeEmpty); err != nil {
return nil, err
}
bz = buf.Bytes()
bz = copyBytes(buf.Bytes())
} else {
// The passed in BinFieldNum is only relevant for when the type is to
// be encoded unpacked (elements are Typ3_ByteLength). In that case,
Expand All @@ -387,7 +390,7 @@ func (cdc *Codec) MarshalReflect(o interface{}) ([]byte, error) {
if err != nil {
return nil, err
}
bz = buf.Bytes()
bz = copyBytes(buf.Bytes())
}
// If bz is empty, prefer nil.
if len(bz) == 0 {
Expand Down Expand Up @@ -443,16 +446,23 @@ func (cdc *Codec) MarshalAny(o interface{}) ([]byte, error) {
}

// Encode as interface.
buf := new(bytes.Buffer)
buf := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(buf)
err = cdc.encodeReflectBinaryInterface(buf, iinfo, reflect.ValueOf(&ivar).Elem(), FieldOptions{}, true)
if err != nil {
return nil, err
}
bz := buf.Bytes()
bz := copyBytes(buf.Bytes())

return bz, nil
}

func copyBytes(bz []byte) []byte {
cp := make([]byte, len(bz))
copy(cp, bz)
return cp
}

// Panics if error.
func (cdc *Codec) MustMarshalAny(o interface{}) []byte {
bz, err := cdc.MarshalAny(o)
Expand Down Expand Up @@ -764,15 +774,17 @@ func (cdc *Codec) JSONMarshal(o interface{}) ([]byte, error) {
return []byte("null"), nil
}
rt := rv.Type()
w := new(bytes.Buffer)
w := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(w)
info, err := cdc.getTypeInfoWLock(rt)
if err != nil {
return nil, err
}
if err = cdc.encodeReflectJSON(w, info, rv, FieldOptions{}); err != nil {
return nil, err
}
return w.Bytes(), nil

return copyBytes(w.Bytes()), nil
}

func (cdc *Codec) MarshalJSONAny(o interface{}) ([]byte, error) {
Expand Down Expand Up @@ -802,12 +814,14 @@ func (cdc *Codec) MarshalJSONAny(o interface{}) ([]byte, error) {
}

// Encode as interface.
buf := new(bytes.Buffer)
buf := poolBytesBuffer.Get()
defer poolBytesBuffer.Put(buf)

err = cdc.encodeReflectJSONInterface(buf, iinfo, reflect.ValueOf(&ivar).Elem(), FieldOptions{})
if err != nil {
return nil, err
}
bz := buf.Bytes()
bz := copyBytes(buf.Bytes())

return bz, nil
}
Expand Down Expand Up @@ -863,12 +877,12 @@ func (cdc *Codec) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byt
if err != nil {
return nil, err
}

var out bytes.Buffer
err = json.Indent(&out, bz, prefix, indent)
if err != nil {
if err := json.Indent(&out, bz, prefix, indent); err != nil {
return nil, err
}
return out.Bytes(), nil
return copyBytes(out.Bytes()), nil
}

// ----------------------------------------
Expand Down
Loading

0 comments on commit 681dea2

Please sign in to comment.