Skip to content

Commit a30227f

Browse files
committed
Merge branch 'v2/cosmos/stargate' of github.com:forbole/bdjuno into v2/cosmos/v0.44.x
� Conflicts: � cmd/fix/fix.go � cmd/migrate/v1/config.go � cmd/parse/feegrant/allowance.go � cmd/parse/feegrant/cmd.go � go.mod � go.sum � modules/history/module.go � modules/pricefeed/module.go � modules/registrar.go
2 parents 3c58be8 + 24f726a commit a30227f

File tree

90 files changed

+837
-707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+837
-707
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
- name: Setup Go
2626
uses: actions/setup-go@v2
2727
with:
28-
go-version: 1.15
28+
go-version: 1.17
2929
- name: Test & Create coverage report
3030
run: make install test-unit stop-docker-test
3131
- name: Upload cove coverage
32-
uses: codecov/codecov-action@v2.1.0
32+
uses: codecov/codecov-action@v3
3333
with:
3434
file: ./coverage.txt

CHANGELOG.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## Version v3.0.0
2+
### Notes
3+
This version introduces breaking changes to `transaction` and `message` PostgreSQL tables. It implements PostgreSQL table partitioning to fix slow data retrieval from database that stores large amount of transactions and messages. Read more details about [migrating to v3.0.0](https://docs.bigdipper.live/cosmos-based/parser/migrations/v2.0.0)
4+
5+
### New features
6+
#### CLI
7+
- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Implemented `migrate` command to perform easy migration to higher BDJuno versions
8+
- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Updated `parse-genesis` command to parse genesis file without accessing the node
9+
10+
#### Database
11+
- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Added PostgreSQL table partition to `transaction` and `message` table
12+
- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Created new `messages_by_address` function
13+
14+
### Changes
15+
#### Hasura
16+
- ([\#377](https://github.com/forbole/bdjuno/pull/377)) Updated Hasura metadata
17+
18+
### Dependencies
19+
- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Updated Juno to `v3.0.0`
20+
21+
## Version v2.0.0
22+
### Notes
23+
This version introduces breaking changes to certain address-specific data that is no longer periodically parsed from the node and stored in the database. Instead, the data is now obtained directly from the node when needed using Hasura Actions. Read more details about [migrating to v2.0.0](https://docs.bigdipper.live/cosmos-based/parser/migrations/v2.0.0)
24+
25+
### New features
26+
#### CLI
27+
- ([\#257](https://github.com/forbole/bdjuno/pull/257)) Added `parse-genesis` command to parse the genesis file
28+
- ([\#228](https://github.com/forbole/bdjuno/pull/228)) ([\#248](https://github.com/forbole/bdjuno/pull/248)) Added `fix` command:
29+
- `auth`: fix vesting accounts details
30+
- `blocks`: fix missing blocks and transactions from given start height
31+
- `gov`: fix proposal with given proposal ID
32+
- `staking`: fix validators info at the latest height
33+
34+
#### Hasura Actions
35+
- ([\#329](https://github.com/forbole/bdjuno/pull/329)) Implemented Hasura Actions service to replace periodic queries. If you are using GraphQL queries on your application, you should updated the old queries to use the below new actions instead.
36+
Here's a list of data acquired through Hasura Actions:
37+
- Of a certain address/delegator:
38+
- Account balance (`action_account_balance`)
39+
- Delegation rewards (`action_delegation_reward`)
40+
- Delegator withdraw address (`action_delegator_withdraw_address`)
41+
- Delegations (`action_delegation`)
42+
- Total delegations amount (`action_delegation_total`)
43+
- Unbonding delegations (`action_unbonding_delegation`)
44+
- Total unbonding delegations amount (`action_unbonding_delegation_total`)
45+
- Redelegations (`action_redelegation`)
46+
- Of a certain validator:
47+
- Commission amount (`action_validator_commission_amount`)
48+
- Delegations to this validator (`action_validator_delegations`)
49+
- Redelegations from this validator (`action_validator_redelegations_from`)
50+
- Unbonding delegations (`action_validator_unbonding_delegations`)
51+
- ([\#352](https://github.com/forbole/bdjuno/pull/352)) Added prometheus monitoring to hasura actions
52+
53+
#### Local node support
54+
- Added the support for `node.type = "local"` for parsing a static local node without the usage gRPC queries: [config reference](https://docs.bigdipper.live/cosmos-based/parser/config/config#node).
55+
56+
#### Modules
57+
- ([\#232](https://github.com/forbole/bdjuno/pull/232)) Updated the `x/auth` module support to handle and store `vesting accounts` and `vesting periods` inside the database.
58+
- ([\#276](https://github.com/forbole/bdjuno/pull/276)) Added the support for the `x/feegrant` module (v0.44.x)
59+
60+
### Changes
61+
62+
#### CLI
63+
- ([\#351](https://github.com/forbole/bdjuno/pull/351)) Fixed version display for `bdjuno version` cmd
64+
65+
#### Database
66+
- ([\#300](https://github.com/forbole/bdjuno/pull/300)) Changed `bonded_tokens` and `not_bonded_tokens` type inside `staking_pool` table to `TEXT` to avoid value overflow
67+
- ([\#275](https://github.com/forbole/bdjuno/pull/275)) Added `tombstoned` column inside `validator_status` table
68+
- ([\#232](https://github.com/forbole/bdjuno/pull/232)) Added `vesting_account` and `vesting_period` table
69+
- ([\#276](https://github.com/forbole/bdjuno/pull/276)) Added `fee_grant_allowance` table (v0.44.x)
70+
71+
#### Modules
72+
- ([\#353](https://github.com/forbole/bdjuno/pull/353)) Removed the support for the `history` module

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ all: lint build test-unit
1313
### Build flags ###
1414
###############################################################################
1515

16-
LD_FLAGS = -X github.com/forbole/juno/v2/cmd.Version=$(VERSION) \
17-
-X github.com/forbole/juno/v2/cmd.Commit=$(COMMIT)
16+
LD_FLAGS = -X github.com/forbole/juno/v3/cmd.Version=$(VERSION) \
17+
-X github.com/forbole/juno/v3/cmd.Commit=$(COMMIT)
1818
BUILD_FLAGS := -ldflags '$(LD_FLAGS)'
1919

2020

cmd/actions/actionscmd.go

+26-12
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,41 @@ import (
88

99
"github.com/rs/zerolog/log"
1010

11-
"github.com/forbole/juno/v2/cmd/parse"
12-
"github.com/forbole/juno/v2/node/builder"
13-
nodeconfig "github.com/forbole/juno/v2/node/config"
14-
"github.com/forbole/juno/v2/node/remote"
11+
types "github.com/forbole/juno/v3/cmd/parse/types"
12+
"github.com/forbole/juno/v3/node/builder"
13+
nodeconfig "github.com/forbole/juno/v3/node/config"
14+
"github.com/forbole/juno/v3/node/remote"
15+
"github.com/forbole/juno/v3/parser"
16+
1517
"github.com/spf13/cobra"
1618

1719
"github.com/forbole/bdjuno/v2/cmd/actions/handlers"
1820
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
1921
"github.com/forbole/bdjuno/v2/modules"
22+
"github.com/forbole/juno/v3/types/config"
2023
)
2124

2225
const (
23-
flagGRPC = "grpc"
24-
flagRPC = "rpc"
25-
flagSecure = "secure"
26-
flagPort = "port"
26+
flagGRPC = "grpc"
27+
flagRPC = "rpc"
28+
flagSecure = "secure"
29+
flagPort = "port"
30+
flagPortPrometheus = "prometheus-port"
31+
flagEablePrometheus = "enable-prometheus"
2732
)
2833

2934
var (
3035
waitGroup sync.WaitGroup
3136
)
3237

3338
// NewActionsCmd returns the Cobra command allowing to activate hasura actions
34-
func NewActionsCmd(parseCfg *parse.Config) *cobra.Command {
39+
func NewActionsCmd(parseCfg *types.Config) *cobra.Command {
3540
cmd := &cobra.Command{
3641
Use: "hasura-actions",
3742
Short: "Activate hasura actions",
38-
PreRunE: parse.ReadConfig(parseCfg),
43+
PreRunE: types.ReadConfigPreRunE(parseCfg),
3944
RunE: func(cmd *cobra.Command, args []string) error {
40-
parseCtx, err := parse.GetParsingContext(parseCfg)
45+
parseCtx, err := types.GetParserContext(config.Cfg, parseCfg)
4146
if err != nil {
4247
return err
4348
}
@@ -47,6 +52,8 @@ func NewActionsCmd(parseCfg *parse.Config) *cobra.Command {
4752
gRPC, _ := cmd.Flags().GetString(flagGRPC)
4853
secure, _ := cmd.Flags().GetBool(flagSecure)
4954
port, _ := cmd.Flags().GetUint(flagPort)
55+
prometheusPort, _ := cmd.Flags().GetUint(flagPortPrometheus)
56+
enablePrometheus, _ := cmd.Flags().GetBool(flagEablePrometheus)
5057

5158
log.Info().Str(flagRPC, rpc).Str(flagGRPC, gRPC).Bool(flagSecure, secure).
5259
Msg("Listening to incoming Hasura actions requests....")
@@ -106,6 +113,11 @@ func NewActionsCmd(parseCfg *parse.Config) *cobra.Command {
106113
waitGroup.Add(1)
107114
go worker.Start(port)
108115

116+
// Start Prometheus
117+
if enablePrometheus {
118+
go actionstypes.StartPrometheus(prometheusPort)
119+
}
120+
109121
// Block main process (signal capture will call WaitGroup's Done)
110122
waitGroup.Wait()
111123
return nil
@@ -116,13 +128,15 @@ func NewActionsCmd(parseCfg *parse.Config) *cobra.Command {
116128
cmd.Flags().String(flagGRPC, "http://127.0.0.1:9090", "GRPC listen address. Port required")
117129
cmd.Flags().Bool(flagSecure, false, "Activate secure connections")
118130
cmd.Flags().Uint(flagPort, 3000, "Port to be used to expose the service")
131+
cmd.Flags().Uint(flagPortPrometheus, 3001, "Port to be used to run hasura prometheus monitoring")
132+
cmd.Flags().Bool(flagEablePrometheus, false, "Enable prometheus monitoring")
119133

120134
return cmd
121135
}
122136

123137
// trapSignal will listen for any OS signal and invoke Done on the main
124138
// WaitGroup allowing the main process to gracefully exit.
125-
func trapSignal(parseCtx *parse.Context) {
139+
func trapSignal(parseCtx *parser.Context) {
126140
var sigCh = make(chan os.Signal)
127141

128142
signal.Notify(sigCh, syscall.SIGTERM)

cmd/actions/handlers/account_balance.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ package handlers
33
import (
44
"fmt"
55

6+
"github.com/rs/zerolog/log"
7+
68
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
79
)
810

911
func AccountBalanceHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
12+
log.Debug().Str("address", payload.GetAddress()).
13+
Int64("height", payload.Input.Height).
14+
Msg("executing account balance action")
15+
1016
height, err := ctx.GetHeight(payload)
1117
if err != nil {
1218
return nil, err

cmd/actions/handlers/delegation.go

+12
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@ package handlers
22

33
import (
44
"fmt"
5+
"strings"
6+
7+
"google.golang.org/grpc/codes"
58

69
sdk "github.com/cosmos/cosmos-sdk/types"
10+
"github.com/rs/zerolog/log"
711

812
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
913
)
1014

1115
func DelegationHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
16+
log.Debug().Str("action", "delegations").
17+
Str("address", payload.GetAddress()).
18+
Msg("executing delegations action")
19+
1220
height, err := ctx.GetHeight(payload)
1321
if err != nil {
1422
return nil, err
@@ -17,6 +25,10 @@ func DelegationHandler(ctx *actionstypes.Context, payload *actionstypes.Payload)
1725
// Get delegator's total rewards
1826
res, err := ctx.Sources.StakingSource.GetDelegationsWithPagination(height, payload.GetAddress(), payload.GetPagination())
1927
if err != nil {
28+
// For stargate only, returns without throwing error if delegator delegations are not found on the chain
29+
if strings.Contains(err.Error(), codes.NotFound.String()) {
30+
return err, nil
31+
}
2032
return err, fmt.Errorf("error while getting delegator delegations: %s", err)
2133
}
2234

cmd/actions/handlers/delegation_total.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ package handlers
22

33
import (
44
"fmt"
5+
"strings"
56

67
sdk "github.com/cosmos/cosmos-sdk/types"
8+
"github.com/rs/zerolog/log"
9+
"google.golang.org/grpc/codes"
710

811
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
912
)
1013

1114
func TotalDelegationAmountHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
15+
log.Debug().Str("address", payload.GetAddress()).
16+
Int64("height", payload.Input.Height).
17+
Msg("executing total delegation amount action")
18+
1219
height, err := ctx.GetHeight(payload)
1320
if err != nil {
1421
return nil, err
@@ -17,7 +24,11 @@ func TotalDelegationAmountHandler(ctx *actionstypes.Context, payload *actionstyp
1724
// Get all delegations for given delegator address
1825
delegationList, err := ctx.Sources.StakingSource.GetDelegationsWithPagination(height, payload.GetAddress(), nil)
1926
if err != nil {
20-
return nil, fmt.Errorf("error while getting delegator delegations: %s", err)
27+
// For stargate only, returns without throwing error if delegator delegations are not found on the chain
28+
if strings.Contains(err.Error(), codes.NotFound.String()) {
29+
return err, nil
30+
}
31+
return err, fmt.Errorf("error while getting delegator delegations: %s", err)
2132
}
2233

2334
var coinObject sdk.Coins

cmd/actions/handlers/delegator_reward.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ package handlers
33
import (
44
"fmt"
55

6+
"github.com/rs/zerolog/log"
7+
68
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
79
)
810

911
func DelegationRewardHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
12+
log.Debug().Str("address", payload.GetAddress()).
13+
Int64("height", payload.Input.Height).
14+
Msg("executing delegation rewards action")
15+
1016
height, err := ctx.GetHeight(payload)
1117
if err != nil {
1218
return nil, err

cmd/actions/handlers/delegator_withdraw_address.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ package handlers
33
import (
44
"fmt"
55

6+
"github.com/rs/zerolog/log"
7+
68
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
79
)
810

911
func DelegatorWithdrawAddressHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
12+
log.Debug().Str("address", payload.GetAddress()).
13+
Msg("executing delegator withdraw address action")
14+
1015
// Get latest node height
1116
height, err := ctx.GetHeight(nil)
1217
if err != nil {

cmd/actions/handlers/redelegation.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import (
44
"fmt"
55

66
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
7+
"github.com/rs/zerolog/log"
78

89
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
910
)
1011

1112
func RedelegationHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
13+
log.Debug().Str("address", payload.GetAddress()).
14+
Int64("height", payload.Input.Height).
15+
Msg("executing redelegations action")
16+
1217
height, err := ctx.GetHeight(payload)
1318
if err != nil {
1419
return nil, err

cmd/actions/handlers/unbonding_delegation_total.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ import (
44
"fmt"
55
"math/big"
66

7+
"github.com/rs/zerolog/log"
8+
79
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
810
)
911

1012
func UnbondingDelegationsTotal(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
13+
log.Debug().Str("address", payload.GetAddress()).
14+
Int64("height", payload.Input.Height).
15+
Msg("executing unbonding delegation total action")
16+
1117
height, err := ctx.GetHeight(payload)
1218
if err != nil {
1319
return nil, err
@@ -16,7 +22,7 @@ func UnbondingDelegationsTotal(ctx *actionstypes.Context, payload *actionstypes.
1622
// Get all unbonding delegations for given delegator address
1723
unbondingDelegations, err := ctx.Sources.StakingSource.GetUnbondingDelegations(height, payload.GetAddress(), nil)
1824
if err != nil {
19-
return nil, fmt.Errorf("error while getting delegator delegations: %s", err)
25+
return nil, fmt.Errorf("error while getting delegator unbonding delegations: %s", err)
2026
}
2127

2228
// Get the bond denom type

cmd/actions/handlers/unbonding_delegations.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ package handlers
33
import (
44
"fmt"
55

6+
"github.com/rs/zerolog/log"
7+
68
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
79
)
810

911
func UnbondingDelegationsHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
12+
log.Debug().Str("address", payload.GetAddress()).
13+
Int64("height", payload.Input.Height).
14+
Msg("executing unbonding delegations action")
15+
1016
height, err := ctx.GetHeight(payload)
1117
if err != nil {
1218
return nil, err
@@ -15,7 +21,7 @@ func UnbondingDelegationsHandler(ctx *actionstypes.Context, payload *actionstype
1521
// Get all unbonding delegations for given delegator address
1622
unbondingDelegations, err := ctx.Sources.StakingSource.GetUnbondingDelegations(height, payload.GetAddress(), payload.GetPagination())
1723
if err != nil {
18-
return nil, fmt.Errorf("error while getting delegator delegations: %s", err)
24+
return nil, fmt.Errorf("error while getting delegator unbonding delegations: %s", err)
1925
}
2026

2127
unbondingDelegationsList := make([]actionstypes.UnbondingDelegation, len(unbondingDelegations.UnbondingResponses))

cmd/actions/handlers/validator_commission.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ package handlers
33
import (
44
"fmt"
55

6+
"github.com/rs/zerolog/log"
7+
68
actionstypes "github.com/forbole/bdjuno/v2/cmd/actions/types"
79
)
810

911
func ValidatorCommissionAmountHandler(ctx *actionstypes.Context, payload *actionstypes.Payload) (interface{}, error) {
12+
log.Debug().Str("address", payload.GetAddress()).
13+
Int64("height", payload.Input.Height).
14+
Msg("executing validator commission action")
15+
1016
// Get latest node height
1117
height, err := ctx.GetHeight(nil)
1218
if err != nil {

0 commit comments

Comments
 (0)