Skip to content

Commit

Permalink
feat: Sync upstream changes on BDJuno v0.3.4 [DEV-1715] (#25)
Browse files Browse the repository at this point in the history
* chore: release v3.2.0

* build(deps): bump github.com/prometheus/client_golang from 1.12.2 to 1.13.0 (forbole#447)

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.2 to 1.13.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/prometheus/client_golang/releases">github.com/prometheus/client_golang's releases</a>.</em></p>
<blockquote>
<h2>## 1.13.0 / 2022-08-06</h2>
<ul>
<li>[CHANGE] Minimum required Go version is now 1.17 (we also test client_golang against the new 1.19 version).</li>
<li>[ENHANCEMENT] Added <code>prometheus.TransactionalGatherer</code> interface for <code>promhttp.Handler</code> use which allows using low allocation update techniques for custom collectors. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/989">#989</a></li>
<li>[ENHANCEMENT] Added exemplar support to <code>prometheus.NewConstHistogram</code>. See <a href="https://github.com/prometheus/client_golang/blob/HEAD/prometheus/examples_test.go#L602"><code>ExampleNewConstHistogram_WithExemplar</code></a> example on how to use it. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/986">#986</a></li>
<li>[ENHANCEMENT] <code>prometheus/push.Pusher</code> now has context-aware methods that pass context to HTTP requests. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1028">#1028</a></li>
<li>[ENHANCEMENT] <code>prometheus/push.Pusher</code> has now <code>Error</code> method that retrieve last error. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1075">#1075</a></li>
<li>[ENHANCEMENT] <code>testutil.GatherAndCompare</code> provides now readable diff on failed comparisons. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/998">#998</a></li>
<li>[ENHANCEMENT] Query API now supports timeouts. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1014">#1014</a></li>
<li>[ENHANCEMENT] New <code>MetricVec</code> method <code>DeletePartialMatch(labels Labels)</code> for deleting all metrics that match provided labels. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1013">#1013</a></li>
<li>[ENHANCEMENT] <code>api.Config</code> now accepts passing custom <code>*http.Client</code>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1025">#1025</a></li>
<li>[BUGFIX] Raise exemplar labels limit from 64 to 128 bytes as specified in OpenMetrics spec. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1091">#1091</a></li>
<li>[BUGFIX] Allow adding exemplar to +Inf bucket to const histograms. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1094">#1094</a></li>
<li>[ENHANCEMENT] Most <code>promhttp.Instrument*</code> middlewares now support adding exemplars to metrics. This allows hooking those to your tracing middleware that retrieves trace ID and puts it in exemplar if present. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1055">#1055</a></li>
<li>[ENHANCEMENT] Added <code>testutil.ScrapeAndCompare</code> method. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1043">#1043</a></li>
<li>[BUGFIX] Fixed <code>GopherJS</code> build support. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/897">#897</a></li>
<li>[ENHANCEMENT] ⚠️ Added way to specify what <code>runtime/metrics</code>  <code>collectors.NewGoCollector</code> should use. See <a href="https://github.com/prometheus/client_golang/blob/HEAD/prometheus/collectors/go_collector_latest_test.go#L263"><code>ExampleGoCollector_WithAdvancedGoMetrics</code></a>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1102">#1102</a></li>
</ul>
<h2>New Contributors ❤️</h2>
<ul>
<li><a href="https://github.com/alissa-tung"><code>@​alissa-tung</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1000">prometheus/client_golang#1000</a></li>
<li><a href="https://github.com/wperron"><code>@​wperron</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/986">prometheus/client_golang#986</a></li>
<li><a href="https://github.com/zhijian-pro"><code>@​zhijian-pro</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1005">prometheus/client_golang#1005</a></li>
<li><a href="https://github.com/dohnto"><code>@​dohnto</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1021">prometheus/client_golang#1021</a></li>
<li><a href="https://github.com/tatsuhiro-t"><code>@​tatsuhiro-t</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1028">prometheus/client_golang#1028</a></li>
<li><a href="https://github.com/sourikghosh"><code>@​sourikghosh</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/998">prometheus/client_golang#998</a></li>
<li><a href="https://github.com/josephwoodward"><code>@​josephwoodward</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1014">prometheus/client_golang#1014</a></li>
<li><a href="https://github.com/stone-z"><code>@​stone-z</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1013">prometheus/client_golang#1013</a></li>
<li><a href="https://github.com/yolossn"><code>@​yolossn</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1025">prometheus/client_golang#1025</a></li>
<li><a href="https://github.com/xrstf"><code>@​xrstf</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1039">prometheus/client_golang#1039</a></li>
<li><a href="https://github.com/dependabot"><code>@​dependabot</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1051">prometheus/client_golang#1051</a></li>
<li><a href="https://github.com/sazary"><code>@​sazary</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1056">prometheus/client_golang#1056</a></li>
<li><a href="https://github.com/oiooj"><code>@​oiooj</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1075">prometheus/client_golang#1075</a></li>
<li><a href="https://github.com/fredr"><code>@​fredr</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1095">prometheus/client_golang#1095</a></li>
<li><a href="https://github.com/inosato"><code>@​inosato</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1096">prometheus/client_golang#1096</a></li>
<li><a href="https://github.com/arun-shopify"><code>@​arun-shopify</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/1094">prometheus/client_golang#1094</a></li>
<li><a href="https://github.com/paralin"><code>@​paralin</code></a> made their first contribution in <a href="https://github-redirect.dependabot.com/prometheus/client_golang/pull/897">prometheus/client_golang#897</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md">github.com/prometheus/client_golang's changelog</a>.</em></p>
<blockquote>
<h2>1.13.0 / 2022-08-05</h2>
<ul>
<li>[CHANGE] Minimum required Go version is now 1.17 (we also test client_golang against new 1.19 version).</li>
<li>[ENHANCEMENT] Added <code>prometheus.TransactionalGatherer</code> interface for <code>promhttp.Handler</code> use which allows using low allocation update techniques for custom collectors. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/989">#989</a></li>
<li>[ENHANCEMENT] Added exemplar support to <code>prometheus.NewConstHistogram</code>. See <a href="https://github.com/prometheus/client_golang/blob/main/prometheus/examples_test.go#L602"><code>ExampleNewConstHistogram_WithExemplar</code></a> example on how to use it. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/986">#986</a></li>
<li>[ENHANCEMENT] <code>prometheus/push.Pusher</code> has now context aware methods that pass context to HTTP request. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1028">#1028</a></li>
<li>[ENHANCEMENT] <code>prometheus/push.Pusher</code> has now <code>Error</code> method that retrieve last error. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1075">#1075</a></li>
<li>[ENHANCEMENT] <code>testutil.GatherAndCompare</code> provides now readable diff on failed comparisons. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/998">#998</a></li>
<li>[ENHANCEMENT] Query API now supports timeouts. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1014">#1014</a></li>
<li>[ENHANCEMENT] New <code>MetricVec</code> method <code>DeletePartialMatch(labels Labels)</code> for deleting all metrics that match provided labels. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1013">#1013</a></li>
<li>[ENHANCEMENT] <code>api.Config</code> now accepts passing custom <code>*http.Client</code>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1025">#1025</a></li>
<li>[BUGFIX] Raise exemplar labels limit from 64 to 128 bytes as specified in OpenMetrics spec. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1091">#1091</a></li>
<li>[BUGFIX] Allow adding exemplar to +Inf bucket to const histograms. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1094">#1094</a></li>
<li>[ENHANCEMENT] Most <code>promhttp.Instrument*</code> middlewares now supports adding exemplars to metrics. This allows hooking those to your tracing middleware that retrieves trace ID and put it in exemplar if present. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1055">#1055</a></li>
<li>[ENHANCEMENT] Added <code>testutil.ScrapeAndCompare</code> method. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1043">#1043</a></li>
<li>[BUGFIX] Fixed <code>GopherJS</code> build support. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/897">#897</a></li>
<li>[ENHANCEMENT] ⚠️ Added way to specify what <code>runtime/metrics</code>  <code>collectors.NewGoCollector</code> should use. See <a href="https://github.com/prometheus/client_golang/blob/main/prometheus/collectors/go_collector_latest_test.go#L263"><code>ExampleGoCollector_WithAdvancedGoMetrics</code></a>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1102">#1102</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/prometheus/client_golang/commit/64435fc00ac419bb878a3f9c9658e8353c19a7cd"><code>64435fc</code></a> Cut 1.13.0 (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1110">#1110</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/5b7e8b2e6716df0ceda9df81feb15910c7efa150"><code>5b7e8b2</code></a> collectors.GoCollector: Added rule support for granular metric configuration....</li>
<li><a href="https://github.com/prometheus/client_golang/commit/d44fbbefdd19086a786a7e4a6e215bfc88468ec5"><code>d44fbbe</code></a> Fix build against GopherJS (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/897">#897</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/1638da9ae43be6ff5ad522ca402712e26b4a19c7"><code>1638da9</code></a> testutil: Add ScrapeAndCompare (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1043">#1043</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/c576b951ad94df7cb97d1b3b6f5cdb49315f5721"><code>c576b95</code></a> Generate new Go runtime metrics for go 1.19 (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1105">#1105</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/618194de6ad3db637313666104533639011b470d"><code>618194d</code></a> fix assorted oddities found by golangci-lint (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1040">#1040</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/c7488be2e4081d3afa59e63e221587546c58badf"><code>c7488be</code></a> Added exemplar support to http middleware. (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1055">#1055</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/3faf3bae7076031e56adc1f76d0c2d817410597e"><code>3faf3ba</code></a> Fixed support for unordered input of exemplars. (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1100">#1100</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/44ce5e1ee5015df547c585135d683fbab114dc82"><code>44ce5e1</code></a> Ensure tests verify request params (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1047">#1047</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/807b1ee73c2079346d041019cffb933fa43aaf3d"><code>807b1ee</code></a> explicitly add +inf bucket in withExemplarsMetric (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1094">#1094</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/prometheus/client_golang/compare/v1.12.2...v1.13.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/prometheus/client_golang&package-manager=go_modules&previous-version=1.12.2&new-version=1.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

* fix: remove tombstone from `validator_status` (already exists in `validator_singing_info`) (forbole#443)

## Description

Closes: #XXXX

Removing `tombstone status` from `validator_status` because:
- it makes the code cleaner as `tombstone status` is already stored in `validator_singing_info`
- it saves grpc calls for each validator at each block
- the front-end `graphQL` does not query it from `validator_status` table anyways

c.f. forbole#411



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* build: go v1.18 (forbole#452)

Closes: #XXXX

---

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* build(deps): bump github.com/go-co-op/gocron from 1.16.2 to 1.16.3 (forbole#456)

Bumps [github.com/go-co-op/gocron](https://github.com/go-co-op/gocron) from 1.16.2 to 1.16.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/go-co-op/gocron/releases">github.com/go-co-op/gocron's releases</a>.</em></p>
<blockquote>
<h2>v1.16.3</h2>
<h2>What's Changed</h2>
<ul>
<li>Protect job.RunCount() with mutex by <a href="https://github.com/seunghyupoh3517"><code>@​seunghyupoh3517</code></a> in <a href="https://github-redirect.dependabot.com/go-co-op/gocron/pull/375">go-co-op/gocron#375</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/go-co-op/gocron/compare/v1.16.2...v1.16.3">https://github.com/go-co-op/gocron/compare/v1.16.2...v1.16.3</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/go-co-op/gocron/commit/0099be01d75f8cde9cb14d6fc5beff1cfc10bd72"><code>0099be0</code></a> Protect job.RunCount() with mutex (<a href="https://github-redirect.dependabot.com/go-co-op/gocron/issues/375">#375</a>)</li>
<li>See full diff in <a href="https://github.com/go-co-op/gocron/compare/v1.16.2...v1.16.3">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/go-co-op/gocron&package-manager=go_modules&previous-version=1.16.2&new-version=1.16.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

* feat: updated staking pool values  (forbole#455)

## Description

Closes: [BDU-484](https://forbole.atlassian.net/browse/BDU-484)



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch
- [x] provided a link to the relevant issue or specification
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [x] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* build(deps): bump github.com/go-co-op/gocron from 1.16.3 to 1.17.0 (forbole#459)

Bumps [github.com/go-co-op/gocron](https://github.com/go-co-op/gocron) from 1.16.3 to 1.17.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/go-co-op/gocron/releases">github.com/go-co-op/gocron's releases</a>.</em></p>
<blockquote>
<h2>v1.17.0</h2>
<h2>What's Changed</h2>
<ul>
<li>bump go to 1.19 by <a href="https://github.com/JohnRoesler"><code>@​JohnRoesler</code></a> in <a href="https://github-redirect.dependabot.com/go-co-op/gocron/pull/380">go-co-op/gocron#380</a></li>
<li>add CustomTimer allowing overriding of the time.AfterFunc by <a href="https://github.com/JohnRoesler"><code>@​JohnRoesler</code></a> in <a href="https://github-redirect.dependabot.com/go-co-op/gocron/pull/381">go-co-op/gocron#381</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/go-co-op/gocron/compare/v1.16.3...v1.17.0">https://github.com/go-co-op/gocron/compare/v1.16.3...v1.17.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/go-co-op/gocron/commit/3272c219ee7d6de6f435f182c91fd52f7da8ca98"><code>3272c21</code></a> add CustomTimer allowing overriding of the time.AfterFunc (<a href="https://github-redirect.dependabot.com/go-co-op/gocron/issues/381">#381</a>)</li>
<li><a href="https://github.com/go-co-op/gocron/commit/5d9071a9a1151486688cdfabb10ec994b1f3803f"><code>5d9071a</code></a> bump go to 1.19 (<a href="https://github-redirect.dependabot.com/go-co-op/gocron/issues/380">#380</a>)</li>
<li>See full diff in <a href="https://github.com/go-co-op/gocron/compare/v1.16.3...v1.17.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/go-co-op/gocron&package-manager=go_modules&previous-version=1.16.3&new-version=1.17.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

* feat: add daily refetch module (forbole#454)

## Description

Closes: BDU-479



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch
- [x] provided a link to the relevant issue or specification
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [x] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* build(deps): bump github.com/rs/zerolog from 1.27.0 to 1.28.0 (forbole#460)

Bumps [github.com/rs/zerolog](https://github.com/rs/zerolog) from 1.27.0 to 1.28.0.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/rs/zerolog/commit/d894f123bc5c2a887c95e90218b9410563141d67"><code>d894f12</code></a> pass program counter to CallerMarshalFunc (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/457">#457</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/4099072c03f2f4e61fa08f70adf9a25983f0cd8e"><code>4099072</code></a> Support extra arbitrary data at the end of console log (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/416">#416</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/4c85986254a5d411779c1ec553a12094042f56a0"><code>4c85986</code></a> Unixnano time format support (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/454">#454</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/43be3013864af78038c42de900a4d78eae0f1d22"><code>43be301</code></a> Bump actions/cache from 3.0.1 to 3.0.5 (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/453">#453</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/afdf9978ec10b0f5a240f174fcdc6e58e06f0dca"><code>afdf997</code></a> Revert &quot;remove fields written into &quot;PartsOrder&quot; (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/383">#383</a>)&quot;</li>
<li><a href="https://github.com/rs/zerolog/commit/14d6629e41683140550f25e6706381efda008968"><code>14d6629</code></a> hlog: adds ProtoHandler (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/396">#396</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/dbdec88d16a2f50ebbdf3a055fe501e075968c91"><code>dbdec88</code></a> Use everywhere InterfaceMarshalFunc (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/414">#414</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/b30730fab2c86649b5e93525f114cfdd3a98c866"><code>b30730f</code></a> Show local time in console (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/415">#415</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/68a6bd49b5bdd0ddc4293bdf503462ea2a3c151e"><code>68a6bd4</code></a> Bump github.com/rs/xid from 1.3.0 to 1.4.0 (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/430">#430</a>)</li>
<li><a href="https://github.com/rs/zerolog/commit/5c08a2724f6816f006445ecf6464ae4d932c529a"><code>5c08a27</code></a> Bump actions/cache from 2 to 3.0.1 (<a href="https://github-redirect.dependabot.com/rs/zerolog/issues/432">#432</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/rs/zerolog/compare/v1.27.0...v1.28.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/rs/zerolog&package-manager=go_modules&previous-version=1.27.0&new-version=1.28.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

* fix: parse gov genesis with `doc.InitialHeight` instead of height 1 (forbole#461)

## Description

Closes: #XXXX



jira: https://forbole.atlassian.net/browse/BDU-544

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [x] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

* build(deps): bump github.com/lib/pq from 1.10.6 to 1.10.7 (forbole#463)

Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.6 to 1.10.7.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/lib/pq/commit/d5affd5073b06f745459768de35356df2e5fd91d"><code>d5affd5</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/lib/pq/issues/1088">#1088</a> from kelvich/sni_support</li>
<li><a href="https://github.com/lib/pq/commit/d65e6ae4bdd1c86b16cd6d2bcff4fe970dc697b4"><code>d65e6ae</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/lib/pq/issues/1083">#1083</a> from nhooyr/fix-receiver-51e2</li>
<li><a href="https://github.com/lib/pq/commit/957fc0b40156534f8dd356bc81679d7e1365242b"><code>957fc0b</code></a> Set SNI for TSL connections</li>
<li><a href="https://github.com/lib/pq/commit/89fee896440712bc328c9087ea185c3990053f31"><code>89fee89</code></a> Use pointer receiver on pq.Error.Error()</li>
<li>See full diff in <a href="https://github.com/lib/pq/compare/v1.10.6...v1.10.7">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/lib/pq&package-manager=go_modules&previous-version=1.10.6&new-version=1.10.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

* Update go.mod

* Fix go.mod

Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aaron <76254323+huichiaotsou@users.noreply.github.com>
Co-authored-by: Magic Cat <37407870+MonikaCat@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 8, 2022
1 parent 3e3782a commit 6f9e39b
Show file tree
Hide file tree
Showing 26 changed files with 326 additions and 120 deletions.
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
## Unreleased
### Dependencies
- ([\#440](https://github.com/forbole/bdjuno/pull/440)) Updated Juno to `v3.3.0`
### Changes
#### Staking Module
- ([\#443](https://github.com/forbole/bdjuno/pull/443)) Remove tombstone status from staking module(already stored in slashing module)
- ([\#455](https://github.com/forbole/bdjuno/pull/455)) Added `unbonding_tokens` and `staked_not_bonded_tokens` values to staking pool table

#### Gov Module
- ([\#461](https://github.com/forbole/bdjuno/pull/461)) Parse `x/gov` genesis with `genesisDoc.InitialHeight` instead of the hard-coded height 1

#### Daily refetch
- ([\#454](https://github.com/forbole/bdjuno/pull/454)) Added `daily refetch` module to refetch missing blocks every day


## Version v3.2.0
### Changes
#### Mint module
- ([\#432](https://github.com/forbole/bdjuno/pull/432)) Update inflation rate when mint param change proposal is passed
Expand All @@ -11,7 +21,7 @@
- ([\#430](https://github.com/forbole/bdjuno/pull/430)) Update the proposals that have invalid status but can still be in voting or deposit periods

### Dependencies
- ([\#412](https://github.com/forbole/bdjuno/pull/412)) Updated Juno to `v3.2.1`
- ([\#440](https://github.com/forbole/bdjuno/pull/440)) Updated Juno to `v3.3.0`

## Version v3.1.0
### Dependencies
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func proposalCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Marshaler, db)
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Marshaler, db)
slashingModule := slashing.NewModule(sources.SlashingSource, parseCtx.EncodingConfig.Marshaler, db)
stakingModule := staking.NewModule(sources.StakingSource, slashingModule, parseCtx.EncodingConfig.Marshaler, db)
stakingModule := staking.NewModule(sources.StakingSource, parseCtx.EncodingConfig.Marshaler, db)

// Build the gov module
govModule := gov.NewModule(sources.GovSource, nil, distrModule, mintModule, slashingModule, stakingModule, parseCtx.EncodingConfig.Marshaler, db)
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/staking/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func validatorsCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
db := database.Cast(parseCtx.Database)

// Build the staking module
stakingModule := staking.NewModule(sources.StakingSource, nil, parseCtx.EncodingConfig.Marshaler, db)
stakingModule := staking.NewModule(sources.StakingSource, parseCtx.EncodingConfig.Marshaler, db)

// Get latest height
height, err := parseCtx.Node.LatestHeight()
Expand Down
24 changes: 24 additions & 0 deletions database/daily_refetch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package database

// GetTotalBlocks implements database.Database
func (db *Db) GetTotalBlocks() (int64, error) {
var blockCount int64
err := db.Sql.QueryRow(`SELECT count(*) FROM block;`).Scan(&blockCount)
return blockCount, err
}

// GetMissingBlocks returns an array of missing blocks from one day ago
func (db *Db) GetMissingBlocks(startHeight, endHeight int64) []int64 {
var result []int64
stmt := `SELECT generate_series($1::int,$2::int) EXCEPT SELECT height FROM block ORDER BY 1;`
err := db.Sqlx.Select(&result, stmt, startHeight, endHeight)
if err != nil {
return nil
}

if len(result) == 0 {
return nil
}

return result
}
8 changes: 8 additions & 0 deletions database/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalStakingPoolSnapshot() {
snapshot := types.NewProposalStakingPoolSnapshot(1, types.NewPool(
sdk.NewInt(100),
sdk.NewInt(200),
sdk.NewInt(20),
sdk.NewInt(30),
10,
))
err := suite.database.SaveProposalStakingPoolSnapshot(snapshot)
Expand All @@ -530,6 +532,8 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalStakingPoolSnapshot() {
err = suite.database.SaveProposalStakingPoolSnapshot(types.NewProposalStakingPoolSnapshot(1, types.NewPool(
sdk.NewInt(200),
sdk.NewInt(500),
sdk.NewInt(14),
sdk.NewInt(10),
9,
)))
suite.Require().NoError(err)
Expand All @@ -551,6 +555,8 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalStakingPoolSnapshot() {
err = suite.database.SaveProposalStakingPoolSnapshot(types.NewProposalStakingPoolSnapshot(1, types.NewPool(
sdk.NewInt(500),
sdk.NewInt(1000),
sdk.NewInt(20),
sdk.NewInt(30),
10,
)))
suite.Require().NoError(err)
Expand All @@ -572,6 +578,8 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalStakingPoolSnapshot() {
err = suite.database.SaveProposalStakingPoolSnapshot(types.NewProposalStakingPoolSnapshot(1, types.NewPool(
sdk.NewInt(1000),
sdk.NewInt(2000),
sdk.NewInt(80),
sdk.NewInt(40),
11,
)))
suite.Require().NoError(err)
Expand Down
11 changes: 6 additions & 5 deletions database/schema/03-staking.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ CREATE INDEX staking_params_height_index ON staking_params (height);

CREATE TABLE staking_pool
(
one_row_id BOOLEAN NOT NULL DEFAULT TRUE PRIMARY KEY,
bonded_tokens TEXT NOT NULL,
not_bonded_tokens TEXT NOT NULL,
height BIGINT NOT NULL,
one_row_id BOOLEAN NOT NULL DEFAULT TRUE PRIMARY KEY,
bonded_tokens TEXT NOT NULL,
not_bonded_tokens TEXT NOT NULL,
unbonding_tokens TEXT NOT NULL,
staked_not_bonded_tokens TEXT NOT NULL,
height BIGINT NOT NULL,
CHECK (one_row_id)
);
CREATE INDEX staking_pool_height_index ON staking_pool (height);
Expand Down Expand Up @@ -70,7 +72,6 @@ CREATE TABLE validator_status
validator_address TEXT NOT NULL REFERENCES validator (consensus_address) PRIMARY KEY,
status INT NOT NULL,
jailed BOOLEAN NOT NULL,
tombstoned BOOLEAN NOT NULL DEFAULT FALSE,
height BIGINT NOT NULL
);
CREATE INDEX validator_status_height_index ON validator_status (height);
Expand Down
13 changes: 10 additions & 3 deletions database/staking_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ import (
// SaveStakingPool allows to save for the given height the given stakingtypes pool
func (db *Db) SaveStakingPool(pool *types.Pool) error {
stmt := `
INSERT INTO staking_pool (bonded_tokens, not_bonded_tokens, height)
VALUES ($1, $2, $3)
INSERT INTO staking_pool (bonded_tokens, not_bonded_tokens, unbonding_tokens, staked_not_bonded_tokens, height)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (one_row_id) DO UPDATE
SET bonded_tokens = excluded.bonded_tokens,
not_bonded_tokens = excluded.not_bonded_tokens,
unbonding_tokens = excluded.unbonding_tokens,
staked_not_bonded_tokens = excluded.staked_not_bonded_tokens,
height = excluded.height
WHERE staking_pool.height <= excluded.height`

_, err := db.Sql.Exec(stmt, pool.BondedTokens.String(), pool.NotBondedTokens.String(), pool.Height)
_, err := db.Sql.Exec(stmt,
pool.BondedTokens.String(),
pool.NotBondedTokens.String(),
pool.UnbondingTokens.String(),
pool.StakedNotBondedTokens.String(),
pool.Height)
if err != nil {
return fmt.Errorf("error while storing staking pool: %s", err)
}
Expand Down
14 changes: 7 additions & 7 deletions database/staking_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

func (suite *DbTestSuite) TestBigDipperDb_SaveStakingPool() {
// Save the data
original := types.NewPool(sdk.NewInt(50), sdk.NewInt(100), 10)
original := types.NewPool(sdk.NewInt(50), sdk.NewInt(100), sdk.NewInt(5), sdk.NewInt(1), 10)
err := suite.database.SaveStakingPool(original)
suite.Require().NoError(err)

// Verify the data
expected := dbtypes.NewStakingPoolRow(50, 100, 10)
expected := dbtypes.NewStakingPoolRow(50, 100, 5, 1, 10)

var rows []dbtypes.StakingPoolRow
err = suite.database.Sqlx.Select(&rows, `SELECT * FROM staking_pool`)
Expand All @@ -25,7 +25,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveStakingPool() {
// ----------------------------------------------------------------------------------------------------------------

// Try updating using a lower height
pool := types.NewPool(sdk.NewInt(1), sdk.NewInt(1), 8)
pool := types.NewPool(sdk.NewInt(1), sdk.NewInt(1), sdk.NewInt(1), sdk.NewInt(1), 8)
err = suite.database.SaveStakingPool(pool)
suite.Require().NoError(err)

Expand All @@ -39,12 +39,12 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveStakingPool() {
// ----------------------------------------------------------------------------------------------------------------

// Try updating with the same height
pool = types.NewPool(sdk.NewInt(1), sdk.NewInt(1), 10)
pool = types.NewPool(sdk.NewInt(1), sdk.NewInt(1), sdk.NewInt(1), sdk.NewInt(1), 10)
err = suite.database.SaveStakingPool(pool)
suite.Require().NoError(err)

// Verify the data
expected = dbtypes.NewStakingPoolRow(1, 1, 10)
expected = dbtypes.NewStakingPoolRow(1, 1, 1, 1, 10)

rows = []dbtypes.StakingPoolRow{}
err = suite.database.Sqlx.Select(&rows, `SELECT * FROM staking_pool`)
Expand All @@ -55,12 +55,12 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveStakingPool() {
// ----------------------------------------------------------------------------------------------------------------

// Try updating with a higher height
pool = types.NewPool(sdk.NewInt(1000000), sdk.NewInt(1000000), 20)
pool = types.NewPool(sdk.NewInt(1000000), sdk.NewInt(1000000), sdk.NewInt(20), sdk.NewInt(15), 20)
err = suite.database.SaveStakingPool(pool)
suite.Require().NoError(err)

// Verify the data
expected = dbtypes.NewStakingPoolRow(1000000, 1000000, 20)
expected = dbtypes.NewStakingPoolRow(1000000, 1000000, 20, 15, 20)

rows = []dbtypes.StakingPoolRow{}
err = suite.database.Sqlx.Select(&rows, `SELECT * FROM staking_pool`)
Expand Down
9 changes: 4 additions & 5 deletions database/staking_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,17 @@ func (db *Db) SaveValidatorsStatuses(statuses []types.ValidatorStatus) error {
validatorStmt := `INSERT INTO validator (consensus_address, consensus_pubkey) VALUES`
var valParams []interface{}

statusStmt := `INSERT INTO validator_status (validator_address, status, jailed, tombstoned, height) VALUES `
statusStmt := `INSERT INTO validator_status (validator_address, status, jailed, height) VALUES `
var statusParams []interface{}

for i, status := range statuses {
vi := i * 2
validatorStmt += fmt.Sprintf("($%d, $%d),", vi+1, vi+2)
valParams = append(valParams, status.ConsensusAddress, status.ConsensusPubKey)

si := i * 5
statusStmt += fmt.Sprintf("($%d,$%d,$%d,$%d,$%d),", si+1, si+2, si+3, si+4, si+5)
statusParams = append(statusParams, status.ConsensusAddress, status.Status, status.Jailed, status.Tombstoned, status.Height)
si := i * 4
statusStmt += fmt.Sprintf("($%d,$%d,$%d,$%d),", si+1, si+2, si+3, si+4)
statusParams = append(statusParams, status.ConsensusAddress, status.Status, status.Jailed, status.Height)
}

validatorStmt = validatorStmt[:len(validatorStmt)-1]
Expand All @@ -432,7 +432,6 @@ func (db *Db) SaveValidatorsStatuses(statuses []types.ValidatorStatus) error {
ON CONFLICT (validator_address) DO UPDATE
SET status = excluded.status,
jailed = excluded.jailed,
tombstoned = excluded.tombstoned,
height = excluded.height
WHERE validator_status.height <= excluded.height`
_, err = db.Sql.Exec(statusStmt, statusParams...)
Expand Down
8 changes: 0 additions & 8 deletions database/staking_validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,13 @@ func (suite *DbTestSuite) TestSaveValidatorStatus() {
validator1.GetConsPubKey(),
1,
false,
false,
10,
),
types.NewValidatorStatus(
validator2.GetConsAddr(),
validator2.GetConsPubKey(),
2,
true,
true,
10,
),
})
Expand All @@ -656,14 +654,12 @@ func (suite *DbTestSuite) TestSaveValidatorStatus() {
dbtypes.NewValidatorStatusRow(
1,
false,
false,
validator1.GetConsAddr(),
10,
),
dbtypes.NewValidatorStatusRow(
2,
true,
true,
validator2.GetConsAddr(),
10,
),
Expand All @@ -680,15 +676,13 @@ func (suite *DbTestSuite) TestSaveValidatorStatus() {
validator1.GetConsPubKey(),
3,
true,
true,
9,
),
types.NewValidatorStatus(
validator2.GetConsAddr(),
validator2.GetConsPubKey(),
3,
true,
true,
11,
),
})
Expand All @@ -703,14 +697,12 @@ func (suite *DbTestSuite) TestSaveValidatorStatus() {
dbtypes.NewValidatorStatusRow(
1,
false,
false,
validator1.GetConsAddr(),
10,
),
dbtypes.NewValidatorStatusRow(
3,
true,
true,
validator2.GetConsAddr(),
11,
),
Expand Down
24 changes: 15 additions & 9 deletions database/types/staking_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@ package types

// StakingPoolRow represents a single row inside the staking_pool table
type StakingPoolRow struct {
OneRowID bool `db:"one_row_id"`
BondedTokens int64 `db:"bonded_tokens"`
NotBondedTokens int64 `db:"not_bonded_tokens"`
Height int64 `db:"height"`
OneRowID bool `db:"one_row_id"`
BondedTokens int64 `db:"bonded_tokens"`
NotBondedTokens int64 `db:"not_bonded_tokens"`
UnbondingTokens int64 `db:"unbonding_tokens"`
StakedNotBondedTokens int64 `db:"staked_not_bonded_tokens"`
Height int64 `db:"height"`
}

// NewStakingPoolRow allows to easily create a new StakingPoolRow
func NewStakingPoolRow(bondedTokens, notBondedTokens int64, height int64) StakingPoolRow {
func NewStakingPoolRow(bondedTokens, notBondedTokens, unbondingTokens, stakedNotBondedTokens int64, height int64) StakingPoolRow {
return StakingPoolRow{
OneRowID: true,
BondedTokens: bondedTokens,
NotBondedTokens: notBondedTokens,
Height: height,
OneRowID: true,
BondedTokens: bondedTokens,
NotBondedTokens: notBondedTokens,
UnbondingTokens: unbondingTokens,
StakedNotBondedTokens: stakedNotBondedTokens,
Height: height,
}
}

// Equal allows to tells whether r and as represent the same rows
func (r StakingPoolRow) Equal(s StakingPoolRow) bool {
return r.BondedTokens == s.BondedTokens &&
r.NotBondedTokens == s.NotBondedTokens &&
r.UnbondingTokens == s.UnbondingTokens &&
r.StakedNotBondedTokens == s.StakedNotBondedTokens &&
r.Height == s.Height
}
5 changes: 1 addition & 4 deletions database/types/staking_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,15 @@ func (v ValidatorVotingPowerRow) Equal(w ValidatorVotingPowerRow) bool {
type ValidatorStatusRow struct {
Status int `db:"status"`
Jailed bool `db:"jailed"`
Tombstoned bool `db:"tombstoned"`
ConsAddress string `db:"validator_address"`
Height int64 `db:"height"`
}

// NewValidatorStatusRow builds a new ValidatorStatusRow
func NewValidatorStatusRow(status int, jailed bool, tombstoned bool, consAddess string, height int64) ValidatorStatusRow {
func NewValidatorStatusRow(status int, jailed bool, consAddess string, height int64) ValidatorStatusRow {
return ValidatorStatusRow{
Status: status,
Jailed: jailed,
Tombstoned: tombstoned,
ConsAddress: consAddess,
Height: height,
}
Expand All @@ -259,7 +257,6 @@ func NewValidatorStatusRow(status int, jailed bool, tombstoned bool, consAddess
func (v ValidatorStatusRow) Equal(w ValidatorStatusRow) bool {
return v.Status == w.Status &&
v.Jailed == w.Jailed &&
v.Tombstoned == w.Tombstoned &&
v.ConsAddress == w.ConsAddress &&
v.Height == w.Height
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ select_permissions:
- height
- bonded_tokens
- not_bonded_tokens
- unbonding_tokens
- staked_not_bonded_tokens
filter: {}
role: anonymous
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ select_permissions:
- validator_address
- status
- jailed
- tombstoned
- height
filter: {}
role: anonymous
Loading

0 comments on commit 6f9e39b

Please sign in to comment.