diff --git a/service/state/core_access.go b/service/state/core_access.go index b0320503fe..a3b620e9f1 100644 --- a/service/state/core_access.go +++ b/service/state/core_access.go @@ -9,6 +9,7 @@ import ( sdktx "github.com/cosmos/cosmos-sdk/types/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" proofutils "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types" + logging "github.com/ipfs/go-log/v2" rpcclient "github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client/http" "google.golang.org/grpc" @@ -21,6 +22,8 @@ import ( "github.com/celestiaorg/nmt/namespace" ) +var log = logging.Logger("state") + // CoreAccessor implements Accessor over a gRPC connection // with a celestia-core node. type CoreAccessor struct { @@ -157,6 +160,14 @@ func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*B } // unmarshal balance information value := result.Response.Value + // if the value returned is empty, the account balance does not yet exist + if len(value) == 0 { + log.Errorf("balance for account %s does not exist at block height %d", addr.String(), head.Height) + return &Balance{ + Denom: app.BondDenom, + Amount: sdktypes.NewInt(0), + }, nil + } coin, ok := sdktypes.NewIntFromString(string(value)) if !ok { return nil, fmt.Errorf("cannot convert %s into sdktypes.Int", string(value))