Skip to content

Commit 8cef508

Browse files
committed
Fixed missing account handling
1 parent 332c508 commit 8cef508

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

pkg/solana/ccip/chainaccessor/config.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package chainaccessor
33
import (
44
"context"
55
"encoding/binary"
6+
"errors"
67
"fmt"
78
"slices"
89

910
"github.com/gagliardetto/solana-go"
11+
"github.com/gagliardetto/solana-go/rpc"
1012
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
1113

1214
offramp "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/latest/ccip_offramp"
@@ -132,11 +134,14 @@ func (a *SolanaAccessor) getOffRampSourceChainConfigs(ctx context.Context, sourc
132134

133135
var sourceChain offramp.SourceChain
134136
err = a.client.GetAccountDataBorshInto(ctx, sourceChainPDA, &sourceChain)
137+
// The plugin is built with EVM behaviour in mind: if account is not found insert entry for chain with source chain config disabled
138+
if errors.Is(err, rpc.ErrNotFound) {
139+
sourceChainConfigs[selector] = ccipocr3.SourceChainConfig{
140+
IsEnabled: false,
141+
}
142+
}
135143
if err != nil {
136-
// TODO: Do we want to return what we can or is a failure to find a source chain config here something we should break at.
137-
// The feed chain selector seems to be included in the list so continuing seems the right move
138-
a.lggr.Debugw("could not find source chain config for selector", "selector", selector)
139-
continue
144+
return nil, fmt.Errorf("failed to fetch source chain config for selector %d: %w", selector, err)
140145
}
141146

142147
a.lggr.Debugw("fetching source chain config", "sourceChainSelector", selector, "offramp", offrampAddr.String(), "sourceChainPDA", sourceChainPDA.String(), "sourceChain", sourceChain)
@@ -278,7 +283,7 @@ func (a *SolanaAccessor) getOfframpConfig(ctx context.Context, offrampAddr solan
278283
}
279284

280285
func (a *SolanaAccessor) getOfframpReferenceAddresses(ctx context.Context, offrampAddr solana.PublicKey) (offramp.ReferenceAddresses, error) {
281-
a.lggr.Debugw("getOfframpReferenceAddresses", "offrampAddr", offrampAddr.String(), "")
286+
a.lggr.Debugw("getOfframpReferenceAddresses", "offrampAddr", offrampAddr.String())
282287
refAddrPDA, _, err := state.FindOfframpReferenceAddressesPDA(offrampAddr)
283288
if err != nil {
284289
return offramp.ReferenceAddresses{}, fmt.Errorf("failed to calculate the offramp reference addresses PDA: %w", err)

pkg/solana/ccip/chainaccessor/solana_accessor.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/gagliardetto/solana-go"
13+
"github.com/gagliardetto/solana-go/rpc"
1314

1415
"github.com/smartcontractkit/chainlink-common/pkg/logger"
1516
"github.com/smartcontractkit/chainlink-common/pkg/types"
@@ -582,9 +583,18 @@ func (a *SolanaAccessor) GetChainFeePriceUpdate(ctx context.Context, selectors [
582583

583584
var destChain feequoter.DestChain
584585
err = a.client.GetAccountDataBorshInto(ctx, destChainPDA, &destChain)
585-
if err != nil {
586+
// The plugin is built with EVM behaviour in mind: if account is not found the zero value is returned
587+
if errors.Is(err, rpc.ErrNotFound) {
588+
feePriceUpdates[sel] = ccipocr3.TimestampedBig{
589+
Value: ccipocr3.NewBigIntFromInt64(0),
590+
Timestamp: time.Time{},
591+
}
586592
continue
587593
}
594+
if err != nil {
595+
a.lggr.Errorw("failed to batch get chain fee price updates", "err", err)
596+
return nil
597+
}
588598

589599
value := new(big.Int).SetBytes(destChain.State.UsdPerUnitGas.Value[:])
590600
feePriceUpdates[sel] = ccipocr3.TimestampedBig{

0 commit comments

Comments
 (0)