Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCIP-4405: Minor fixes and add unit tests #1559

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 2 additions & 8 deletions core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const (

// defaultCoolDownDurationSec defines the default time to wait after getting rate limited.
// this value is only used if the 429 response does not contain the Retry-After header
defaultCoolDownDuration = 5 * time.Minute

// maxCoolDownDuration defines the maximum duration we can wait till firing the next request
maxCoolDownDuration = 10 * time.Minute
defaultCoolDownDuration = 30 * time.Second

// defaultRequestInterval defines the rate in requests per second that the attestation API can be called.
// this is set according to the APIs recommended 5 requests per second rate limit.
Expand Down Expand Up @@ -204,7 +201,7 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E

attestationResp, err := s.callAttestationApi(ctx, payloadHash)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed calling lbtc attestation API")
}
if attestationResp.Attestations == nil || len(attestationResp.Attestations) == 0 {
return nil, errors.New("attestation response is empty")
Expand Down Expand Up @@ -263,9 +260,6 @@ func (s *TokenDataReader) callAttestationApi(ctx context.Context, lbtcMessageHas

func (s *TokenDataReader) setCoolDownPeriod(d time.Duration) {
s.coolDownMu.Lock()
if d > maxCoolDownDuration {
d = maxCoolDownDuration
}
s.coolDownUntil = time.Now().Add(d)
s.coolDownMu.Unlock()
}
Expand Down
Loading
Loading