Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/big-buses-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/proof-of-reserves-adapter': minor
---

Add clearer logging
20 changes: 16 additions & 4 deletions packages/composites/proof-of-reserves/src/endpoint/reserves.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test?

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ExecuteWithConfig, InputParameters } from '@chainlink/ea-bootstrap'
import { Validator } from '@chainlink/ea-bootstrap'
import { Logger, Validator } from '@chainlink/ea-bootstrap'
import { Config } from '../config'
import { getValidAddresses } from '../utils/addressValidator'
import {
Expand Down Expand Up @@ -140,9 +140,21 @@ export const execute: ExecuteWithConfig<Config> = async (input, context, config)
const currentUTC = new Date()

if (currentUTC < startUTC || currentUTC > endUTC) {
throw new Error(
`Skipping request. Current UTC Hour: ${currentUTC} outside schedule window of start: ${startUTC} and end: ${endUTC}`,
)
// Calculate next available window
const nextWindowStart = new Date(startUTC)
if (currentUTC > endUTC) {
// If we're past today's window, next window is tomorrow
nextWindowStart.setUTCDate(nextWindowStart.getUTCDate() + 1)
}

const message =
`Skipping execution - outside schedule window. ` +
`JobRunId: ${jobRunID}, ` +
`Current: ${currentUTC.toISOString()}, ` +
`Window: [${startUTC.toISOString()} - ${endUTC.toISOString()}], ` +
`NextWindowStart: ${nextWindowStart.toISOString()}`
Logger.info(message)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will log every 10 seconds while the window is closed, right? Isn't that a lot of log spam?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. I can remove the logging and just it in the error message.

throw new Error(message)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause a 400 or 500 error? Do we want to use an AdapterError and decide explicitly what status code to return?

}
}

Expand Down
Loading