Skip to content

Commit

Permalink
log in rpc error
Browse files Browse the repository at this point in the history
  • Loading branch information
alrxy committed Sep 27, 2024
1 parent c6b1215 commit 3016e3a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x/symStaking/keeper/symbiotic_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ func (k *Keeper) SymbioticUpdateValidatorsPower(ctx context.Context) error {
time.Sleep(time.Millisecond * SLEEP_ON_RETRY)
}

if err != nil {
return err
}

for _, v := range validators {
val, err := k.GetValidatorByConsAddr(ctx, v.ConsAddr[:20])
if err != nil {
Expand Down Expand Up @@ -257,6 +261,7 @@ func (k Keeper) GetMinBlockTimestamp(ctx context.Context) uint64 {
func (k Keeper) getSymbioticValidatorSet(ctx context.Context, blockHash string) ([]Validator, error) {
client, err := ethclient.Dial(k.apiUrls.GetEthApiUrl())
if err != nil {
k.Logger.Error("rpc error: ethclient dial error", "url", k.apiUrls.GetEthApiUrl(), "err", err)
return nil, err
}
defer client.Close()
Expand All @@ -279,6 +284,7 @@ func (k Keeper) getSymbioticValidatorSet(ctx context.Context, blockHash string)
}
result, err := client.CallContractAtHash(ctx, query, common.HexToHash(blockHash))
if err != nil {
k.Logger.Error("rpc error: eth_call error", "url", k.apiUrls.GetEthApiUrl(), "err", err)
return nil, err
}

Expand All @@ -295,6 +301,7 @@ func (k Keeper) getSymbioticValidatorSet(ctx context.Context, blockHash string)
}
result, err = client.CallContractAtHash(ctx, query, common.HexToHash(blockHash))
if err != nil {
k.Logger.Error("rpc error: eth_call error", "url", k.apiUrls.GetEthApiUrl(), "err", err)
return nil, err
}

Expand All @@ -320,10 +327,15 @@ func (k Keeper) parseBlock(slot int) (Block, error) {
var block Block
resp, err := http.Get(url)
if err != nil {
k.Logger.Error("rpc error: beacon rpc call error", "url", url, "err", err)
return block, fmt.Errorf("error making HTTP request: %v", err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
k.Logger.Error("rpc error: beacon rpc call error", "url", k.apiUrls.GetEthApiUrl(), "err", "no err", "status", resp.StatusCode)
}

if resp.StatusCode == http.StatusNotFound {
return block, stakingtypes.ErrSymbioticNotFound
}
Expand Down

0 comments on commit 3016e3a

Please sign in to comment.