Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#4613](https://github.com/ignite/cli/pull/4613) Improve and simplify prompting logic by bubbletea.
- [#4615](https://github.com/ignite/cli/pull/4615) Fetch Ignite announcements from API.
- [#4624](https://github.com/ignite/cli/pull/4624) Fix autocli templates for variadics.
- [#4633](https://github.com/ignite/cli/pull/4633) Loosen faucet check when indexer disabled.

### Fixes

Expand Down
11 changes: 11 additions & 0 deletions ignite/pkg/cosmosfaucet/cosmosfaucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type Faucet struct {

// version holds the cosmos-sdk version.
version cosmosver.Version

// indexerDisabled tells whether the indexing is disabled on the node.
indexerDisabled bool
}

// Option configures the faucetOptions.
Expand Down Expand Up @@ -139,6 +142,14 @@ func Version(version cosmosver.Version) Option {
}
}

// IndexerDisabled tells whether the indexing is disabled on the node.
// Without indexing, the faucet won't be able to check the limits for each account, nor verify the transaction status.
func IndexerDisabled() Option {
return func(f *Faucet) {
f.indexerDisabled = true
}
}

// New creates a new faucet with ccr (to access and use blockchain's CLI) and given options.
func New(ctx context.Context, ccr chaincmdrunner.Runner, options ...Option) (Faucet, error) {
f := Faucet{
Expand Down
9 changes: 9 additions & 0 deletions ignite/pkg/cosmosfaucet/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func (f *Faucet) Transfer(ctx context.Context, toAccountAddress string, coins sd
transfer := sdk.NewCoins()
// check for each coin, the max transferred amount hasn't been reached
for _, c := range coins {
if f.indexerDisabled { // we cannot check the transfer history if indexer is disabled
transfer = transfer.Add(c)
continue
}

totalSent, err := f.TotalTransferredAmount(ctx, toAccountAddress, c.Denom)
if err != nil {
return "", err
Expand Down Expand Up @@ -109,6 +114,10 @@ func (f *Faucet) Transfer(ctx context.Context, toAccountAddress string, coins sd
return "", err
}

if f.indexerDisabled {
return txHash, nil // we cannot check the tx status if indexer is disabled
}

// wait for send tx to be confirmed
return txHash, f.runner.WaitTx(ctx, txHash, time.Second, 30)
}
21 changes: 21 additions & 0 deletions ignite/services/chain/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package chain

import (
"context"
"fmt"
"os"
"strings"
"time"

sdkmath "cosmossdk.io/math"
Expand All @@ -14,6 +16,7 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/cosmosfaucet"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/xurl"
"github.com/ignite/cli/v29/ignite/pkg/xyaml"
)

var (
Expand Down Expand Up @@ -84,6 +87,12 @@ func (c *Chain) Faucet(ctx context.Context) (cosmosfaucet.Faucet, error) {
cosmosfaucet.Version(c.Version),
}

// check if indexer is enabled or not.
if indexerDisabled(validator.Config) {
faucetOptions = append(faucetOptions, cosmosfaucet.IndexerDisabled())
c.ev.Send("⚠️ CometBFT indexer disabled. Faucet can't check account limits or verify transaction status.")
}

// parse coins to pass to the faucet as coins.
for _, coin := range conf.Faucet.Coins {
parsedCoin, err := sdk.ParseCoinNormalized(coin)
Expand Down Expand Up @@ -130,3 +139,15 @@ func (c *Chain) Faucet(ctx context.Context) (cosmosfaucet.Faucet, error) {
// init the faucet with options and return.
return cosmosfaucet.New(ctx, commands, faucetOptions...)
}

// indexerDisabled checks if the indexer is disabled in the config.yml.
// More specifically, it checks if a kv indexer is used (psql indexer is not supported).
func indexerDisabled(valCfg xyaml.Map) bool {
const txIndexKey = "tx_index"
v, ok := valCfg[txIndexKey]
if !ok {
return false
}

return !strings.Contains(fmt.Sprintf("%v", v), "kv")
}
Loading