Skip to content

Commit

Permalink
feat: Sync upstream bank and staking features (#63)
Browse files Browse the repository at this point in the history
* build(deps): bump github.com/prometheus/client_golang from 1.13.0 to 1.13.1 (forbole#493)

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.0 to 1.13.1.
<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.1 / 2022-11-02</h2>
<ul>
<li>[BUGFIX] Fix race condition with Exemplar in Counter. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1146">#1146</a></li>
<li>[BUGFIX] Fix <code>CumulativeCount</code> value of <code>+Inf</code> bucket created from exemplar. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1148">#1148</a></li>
<li>[BUGFIX] Fix double-counting bug in <code>promhttp.InstrumentRoundTripperCounter</code>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1118">#1118</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/prometheus/client_golang/compare/v1.13.0...v1.13.1">https://github.com/prometheus/client_golang/compare/v1.13.0...v1.13.1</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/prometheus/client_golang/blob/v1.13.1/CHANGELOG.md">github.com/prometheus/client_golang's changelog</a>.</em></p>
<blockquote>
<h2>1.13.1 / 2022-11-01</h2>
<ul>
<li>[BUGFIX] Fix race condition with Exemplar in Counter. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1146">#1146</a></li>
<li>[BUGFIX] Fix <code>CumulativeCount</code> value of <code>+Inf</code> bucket created from exemplar. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1148">#1148</a></li>
<li>[BUGFIX] Fix double-counting bug in <code>promhttp.InstrumentRoundTripperCounter</code>. <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1118">#1118</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/prometheus/client_golang/commit/53e51c4f5338f760a766232610e574b00ea720d8"><code>53e51c4</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1157">#1157</a> from prometheus/cut-1.13.1</li>
<li><a href="https://github.com/prometheus/client_golang/commit/79ca0eb2ba90a9c1754d29177d0bfe3afb425449"><code>79ca0eb</code></a> Added tip from Björn + Grammarly.</li>
<li><a href="https://github.com/prometheus/client_golang/commit/078f11f85b2cb5d535f5856903e73b758a8f0568"><code>078f11f</code></a> Cut 1.13.1 release (+ documenting release process).</li>
<li><a href="https://github.com/prometheus/client_golang/commit/ddd7f0edcd31dd27b31ee9c54b5c22d44258d5d1"><code>ddd7f0e</code></a> Fix race condition with Exemplar in Counter (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1146">#1146</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/1f93f64580770181b19e685e1a243923fb61d476"><code>1f93f64</code></a> Fix <code>CumulativeCount</code> value of <code>+Inf</code> bucket created from exemplar (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1148">#1148</a>)</li>
<li><a href="https://github.com/prometheus/client_golang/commit/8cc2b6c472a5d4cfc3d9fe37c5a23f7239faf707"><code>8cc2b6c</code></a> Fix double-counting bug in promhttp.InstrumentRoundTripperCounter (<a href="https://github-redirect.dependabot.com/prometheus/client_golang/issues/1118">#1118</a>)</li>
<li>See full diff in <a href="https://github.com/prometheus/client_golang/compare/v1.13.0...v1.13.1">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.13.0&new-version=1.13.1)](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: manually trigger periodic task (forbole#492)

Closes: forbole#415

---

*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`
- [ ] 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

*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)

* fix: check if proposal has passed voting end time before marking it as invalid (forbole#499)

Closes: #XXXX

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

---

*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

*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)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aaron <76254323+huichiaotsou@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 24, 2022
1 parent 1fcb41d commit c31421f
Show file tree
Hide file tree
Showing 20 changed files with 396 additions and 28 deletions.
20 changes: 20 additions & 0 deletions cmd/parse/bank/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bank

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewBankCmd returns the Cobra command allowing to fix various things related to the x/bank module
func NewBankCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "bank",
Short: "Fix things related to the x/bank module",
}

cmd.AddCommand(
supplyCmd(parseConfig),
)

return cmd
}
46 changes: 46 additions & 0 deletions cmd/parse/bank/supply.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package bank

import (
"fmt"

modulestypes "github.com/forbole/bdjuno/v3/modules/types"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/bank"
)

// supplyCmd returns the Cobra command allowing to refresh x/bank total supply
func supplyCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "supply",
Short: "Refresh total supply",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build bank module
bankModule := bank.NewModule(nil, sources.BankSource, parseCtx.EncodingConfig.Marshaler, db)

err = bankModule.UpdateSupply()
if err != nil {
return fmt.Errorf("error while getting latest bank supply: %s", err)
}

return nil
},
}
}
20 changes: 20 additions & 0 deletions cmd/parse/distribution/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package distribution

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewDistributionCmd returns the Cobra command allowing to fix various things related to the x/distribution module
func NewDistributionCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "distribution",
Short: "Fix things related to the x/distribution module",
}

cmd.AddCommand(
communityPoolCmd(parseConfig),
)

return cmd
}
45 changes: 45 additions & 0 deletions cmd/parse/distribution/communitypool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package distribution

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/distribution"
modulestypes "github.com/forbole/bdjuno/v3/modules/types"
)

// communityPoolCmd returns the Cobra command allowing to refresh community pool
func communityPoolCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "community-pool",
Short: "Refresh community pool",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build distribution module
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Marshaler, db)

err = distrModule.GetLatestCommunityPool()
if err != nil {
return fmt.Errorf("error while updating community pool: %s", err)
}

return nil
},
}
}
3 changes: 2 additions & 1 deletion cmd/parse/gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"fmt"
"strconv"
"time"

modulestypes "github.com/forbole/bdjuno/v3/modules/types"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -78,7 +79,7 @@ func proposalCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return fmt.Errorf("error while getting chain latest block height: %s", err)
}

err = govModule.UpdateProposal(height, proposalID)
err = govModule.UpdateProposal(height, time.Now(), proposalID)
if err != nil {
return err
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/parse/mint/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package mint

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewMintCmd returns the Cobra command allowing to fix various things related to the x/mint module
func NewMintCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "mint",
Short: "Fix things related to the x/mint module",
}

cmd.AddCommand(
inflationCmd(parseConfig),
)

return cmd
}
45 changes: 45 additions & 0 deletions cmd/parse/mint/inflation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package mint

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/mint"
modulestypes "github.com/forbole/bdjuno/v3/modules/types"
)

// inflationCmd returns the Cobra command allowing to refresh x/mint inflation
func inflationCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "inflation",
Short: "Refresh inflation",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build mint module
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Marshaler, db)

err = mintModule.UpdateInflation()
if err != nil {
return fmt.Errorf("error while updating inflation: %s", err)
}

return nil
},
}
}
8 changes: 8 additions & 0 deletions cmd/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
parsegenesis "github.com/forbole/juno/v3/cmd/parse/genesis"

parseauth "github.com/forbole/bdjuno/v3/cmd/parse/auth"
parsebank "github.com/forbole/bdjuno/v3/cmd/parse/bank"
parsedistribution "github.com/forbole/bdjuno/v3/cmd/parse/distribution"
parsefeegrant "github.com/forbole/bdjuno/v3/cmd/parse/feegrant"
parsegov "github.com/forbole/bdjuno/v3/cmd/parse/gov"
parsemint "github.com/forbole/bdjuno/v3/cmd/parse/mint"
parsepricefeed "github.com/forbole/bdjuno/v3/cmd/parse/pricefeed"
parsestaking "github.com/forbole/bdjuno/v3/cmd/parse/staking"
parsetransaction "github.com/forbole/juno/v3/cmd/parse/transactions"
)
Expand All @@ -25,10 +29,14 @@ func NewParseCmd(parseCfg *parse.Config) *cobra.Command {

cmd.AddCommand(
parseauth.NewAuthCmd(parseCfg),
parsebank.NewBankCmd(parseCfg),
parseblocks.NewBlocksCmd(parseCfg),
parsedistribution.NewDistributionCmd(parseCfg),
parsefeegrant.NewFeegrantCmd(parseCfg),
parsegenesis.NewGenesisCmd(parseCfg),
parsegov.NewGovCmd(parseCfg),
parsemint.NewMintCmd(parseCfg),
parsepricefeed.NewPricefeedCmd(parseCfg),
parsestaking.NewStakingCmd(parseCfg),
parsetransaction.NewTransactionsCmd(parseCfg),
)
Expand Down
21 changes: 21 additions & 0 deletions cmd/parse/pricefeed/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pricefeed

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewPricefeedCmd returns the Cobra command allowing to refresh pricefeed
func NewPricefeedCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "pricefeed",
Short: "Fix things related to the pricefeed module",
}

cmd.AddCommand(
priceCmd(parseConfig),
priceHistoryCmd(parseConfig),
)

return cmd
}
44 changes: 44 additions & 0 deletions cmd/parse/pricefeed/price.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package pricefeed

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/pricefeed"
)

// priceCmd returns the Cobra command allowing to refresh token price
func priceCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "price",
Short: "Refresh token price",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build pricefeed module
pricefeedModule := pricefeed.NewModule(config.Cfg, parseCtx.EncodingConfig.Marshaler, db)

err = pricefeedModule.RunAdditionalOperations()
if err != nil {
return fmt.Errorf("error while storing tokens: %s", err)
}

err = pricefeedModule.UpdatePrice()
if err != nil {
return fmt.Errorf("error while updating price: %s", err)
}

return nil
},
}
}
44 changes: 44 additions & 0 deletions cmd/parse/pricefeed/pricehistory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package pricefeed

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/pricefeed"
)

// priceHistoryCmd returns the Cobra command allowing to store token price history
func priceHistoryCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "history",
Short: "Store token price history",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build pricefeed module
pricefeedModule := pricefeed.NewModule(config.Cfg, parseCtx.EncodingConfig.Marshaler, db)

err = pricefeedModule.RunAdditionalOperations()
if err != nil {
return fmt.Errorf("error while storing tokens: %s", err)
}

err = pricefeedModule.UpdatePricesHistory()
if err != nil {
return fmt.Errorf("error while updating price history: %s", err)
}

return nil
},
}
}
1 change: 1 addition & 0 deletions cmd/parse/staking/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func NewStakingCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
}

cmd.AddCommand(
poolCmd(parseConfig),
validatorsCmd(parseConfig),
)

Expand Down
Loading

0 comments on commit c31421f

Please sign in to comment.