Skip to content

Commit

Permalink
fix nil pointer bug in GetNetworkInferences (#635)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v           ✰  Thanks for creating a PR! You're awesome! ✰
v Please note that maintainers will only review those PRs with a
completed PR template.
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Purpose of Changes and their Description

There was an occasional nil pointer panic in `GetNetworkInferences`

## Link(s) to Ticket(s) or Issue(s) resolved by this PR


https://linear.app/alloralabs/issue/PROTO-2728/fix-nil-pointer-dereference-panic-in-getnetworkinferences

## Are these changes tested and documented?

- [x] If tested, please describe how. If not, why tests are not needed.
    - Ran the test suite
- [x] If documented, please describe where. If not, describe why docs
are not needed.
- New test cases added for both specific block and latest block.
Confirmed nil pointer bug before implementing fix.
- [x] Added to `Unreleased` section of `CHANGELOG.md`?

## Still Left Todo

🔴 🔴 🔴 There are several places marked `TODO(spook)` that I need some
feedback from the team on. 🔴 🔴 🔴
  • Loading branch information
kpeluso authored Oct 22, 2024
2 parents 1275941 + 7cfa1e7 commit 1c19459
Show file tree
Hide file tree
Showing 20 changed files with 2,681 additions and 2,830 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ linters:
- thelper
- unconvert
- unused
- whitespace
- unparam
- revive
- gosec
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* [#624](https://github.com/allora-network/allora-chain/pull/624) Add `nurse` internal healthcheck service based on `pprof`. See `health/README.md`.
* [#642](https://github.com/allora-network/allora-chain/pull/642) Add release signing keys

### Changed

Expand All @@ -72,6 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#615](https://github.com/allora-network/allora-chain/pull/615) Improvement to merit-based sortition to enable more cycling through the crowd
* [#615](https://github.com/allora-network/allora-chain/pull/615) Fixed runaway regret calculation where large influx of workers would cause the regret to grow negatively without bound
* [#635](https://github.com/allora-network/allora-chain/pull/635) Fixed occasional nil pointer dereference bug when calling `GetNetworkInferences`. Also, actually filled in loss block height return value.

### Added

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
github.com/hashicorp/go-metrics v0.5.3
github.com/ignite/cli/v28 v28.5.3
github.com/pelletier/go-toml/v2 v2.2.3
github.com/pkg/errors v0.9.1
github.com/spf13/cast v1.7.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
Expand Down Expand Up @@ -168,7 +169,6 @@ require (
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions math/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func Median(data []Dec) (Dec, error) {
}

// Sort the data
sort.Slice(data, func(i, j int) bool {
return data[i].Lt(data[j])
slices.SortFunc(data, func(x, y Dec) int {
return x.Cmp(y)
})

if n%2 == 1 {
Expand Down
9 changes: 9 additions & 0 deletions release-signing-keys/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Release Signing Keys

This directory contains the PGP keys used to sign releases of the `allora-chain` project.

You can import the key by running `gpg --import <key>`.

You can check that the signature was created by the key by running `gpg --verify <signature> <release>`. Signatures can be found in the `*.asc` files in the release assets.

Releases and their assets can be taken from the [releases page](https://github.com/allora-network/allora-chain/releases).
52 changes: 52 additions & 0 deletions release-signing-keys/kpeluso
Original file line number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JU2R+43KyI0aJnZYX/ntOlV9dfJigyiTUTlHI/cSCYqplgBus+Nmph
WZneRgVsBNI56qREh6cDHrWX9cB3EoYnNgw6JX7FmyBQF9rzaJoyoFyCg3WOJlGW
Mq5rYbz84/xS8p8tMX1nHLeGWfdd6Ql2QMBXKAT+rh9IEAP1lBneaaVezgvxvCVo
rSXsoARo3s45fSUjokwwtsijNrjJABEBAAGJAjwEGAEIACYWIQQTe1+/HNulUQ89
7E19XkVFvYISfQUCZxfDqAIbDAUJAeEzgAAKCRB9XkVFvYISfRGkEADTtf4QnVNt
HJZkk9Is0sHPuhHYeDqvY3kSsITRfB1OFWrpu1/hLsu7bfN1kxZ6u9oaR8p4J/uZ
SUZmIRnLou+oiqVbSzPRJVMKjKupXxih/MHm7wA7lkgERogE2N6xsrIdKn/iiUzt
JxIPWzKA/kZ4BsaOQN3v/4jgsuMcBNsv3eloTaifo38bo889jodZ8p419YPIoTZe
zjmKAXrTx1MvzYf4SOXpOsGWYRCStSp8MAI4IATMLS5FqL5XcanXeam46QJXY815
OKF5ITnJGHSSdxxhlQdPcyspvw4RQ7WSeq6b1IdK1wxsfE3q5ACntVgoQlsPDZtV
0eNNkfzhIxLOGVAAIxP1kf1ix7iJFz2O9FZPLa8hdwB/lKfrrIcDfqdYFiqlK4Ox
J/JVQIUh7cd/tDJ4bGd8dwb4lJ6ACxgiHBj1bx8LGE9GiAcxn0RBBq95kNcEuiqo
a/Jvli/7z5rmHIzQG0LlgaIm0884XpeSetSmY3QWHGXPExDUr/Pi3rh93cUxBkc2
X0cp1W5S9xr0qvP8tU39Pil9o+1nBiIViJUNXvQRNlSNwXC5KMyoT915yQ5HR3oW
iU882aSq5/4s+lcewRpd7TYVvZ5Dk8UdCPXMBg3p3Caeeb4oe9U2iXqpHCMetTP+
zjvgaHiQdGw7d//Rs3pOzeU3NdkJc5wRsA==
=6oY0
-----END PGP PUBLIC KEY BLOCK-----
9 changes: 9 additions & 0 deletions utils/fn/fn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fn

func Map[S []InType, U []OutType, InType any, OutType any](in S, fn func(InType) OutType) U {
out := make([]OutType, len(in))
for i := range in {
out[i] = fn(in[i])
}
return out
}
Loading

0 comments on commit 1c19459

Please sign in to comment.