Skip to content

Commit

Permalink
code review pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv committed Jul 12, 2024
1 parent 4766bf7 commit 69d11a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions core/services/ocr2/plugins/ccip/internal/ccipdata/usdc_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers"
)

var (
// shortLivedInMemLogsCacheExpiration is used for the short lived in meme logs cache. Value should not be set
// to a very high value as it is used to prevent frequent log fetching (e.g. in caller's a loop).
shortLivedInMemLogsCacheExpiration = 20 * time.Second
)

const (
MESSAGE_SENT_FILTER_NAME = "USDC message sent"
)
Expand Down Expand Up @@ -80,7 +86,7 @@ func (u *USDCReaderImpl) GetUSDCMessagePriorToLogIndexInTx(ctx context.Context,
var lpLogs []logpoller.Log

// fetch all the usdc logs for the provided tx hash
k := fmt.Sprintf("getUsdcMsgPriorToLogIdx-%s", txHash)
k := fmt.Sprintf("usdc-%s", txHash) // custom prefix to avoid key collision if someone re-uses the cache
if rawLogs, foundInMem := u.shortLivedInMemLogs.Get(k); foundInMem {
inMemLogs, ok := rawLogs.([]logpoller.Log)
if !ok {
Expand Down Expand Up @@ -143,7 +149,7 @@ func NewUSDCReader(lggr logger.Logger, jobID string, transmitter common.Address,
Retention: CommitExecLogsRetention,
},
transmitterAddress: transmitter,
shortLivedInMemLogs: cache.New(20*time.Second, time.Minute),
shortLivedInMemLogs: cache.New(shortLivedInMemLogsCacheExpiration, 2*shortLivedInMemLogsCacheExpiration),
}

if registerFilters {
Expand Down
5 changes: 3 additions & 2 deletions core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E
return []byte{}, errors.Wrap(err, "failed calling usdc attestation API ")
}

s.lggr.Infow("Got response from attestation API", "messageBodyHash", msgBody, "messageID", msgID,
"ar.status", attestationResp.Status, "ar.attestation", attestationResp.Attestation, "ar.error", attestationResp.Error)
s.lggr.Infow("Got response from attestation API", "messageID", msgID,
"attestationStatus", attestationResp.Status, "attestation", attestationResp.Attestation,
"attestationError", attestationResp.Error)

switch attestationResp.Status {
case attestationStatusSuccess:
Expand Down

0 comments on commit 69d11a9

Please sign in to comment.