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

Transmit function #15091

Merged
merged 17 commits into from
Nov 8, 2024
Merged

Transmit function #15091

merged 17 commits into from
Nov 8, 2024

Conversation

eduard-cl
Copy link

Modify the transmit function to handle secondary proxy.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

I see you updated files related to contracts. Please run pnpm changeset in the contracts directory to add a changeset.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Static analysis results are available

Hey @Oozyx, you can view Slither reports in the job summary here or download them as artifact here.
Please check them before merging and make sure you have addressed all issues.

contracts/src/v0.8/feeds/DualAggregator.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/feeds/DualAggregator.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/feeds/DualAggregator.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/feeds/DualAggregator.sol Show resolved Hide resolved
contracts/src/v0.8/feeds/DualAggregator.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/feeds/DualAggregator.sol Outdated Show resolved Hide resolved
Base automatically changed from round-call-functions to feeds-project-develop November 5, 2024 10:59
@KMontag42
Copy link

the code itself looks good to me, are there any failing test cases at the moment?

Copy link
Contributor

github-actions bot commented Nov 6, 2024

AER Report: Operator UI CI

aer_workflow , commit , Breaking Changes GQL Check

1. Workflow failed to complete successfully:[convictional/trigger-workflow-and-wait@f69fa9e]

Source of Error:
2024-11-08T15:54:52.6693661Z Checking conclusion [failure]
2024-11-08T15:54:52.6694444Z Checking status [completed]
2024-11-08T15:54:52.6695329Z Conclusion is not success, it's [failure].
2024-11-08T15:54:52.6702183Z Propagating failure to upstream job

Why: The triggered workflow did not complete successfully. The status check returned a conclusion of "failure" instead of "success," causing the upstream job to propagate the failure.

Suggested fix: Investigate the logs of the downstream workflow (ID: 11745315311) to identify the specific reason for the failure and address the underlying issue.

AER Report: CI Core ran successfully ✅

aer_workflow , commit

@Oozyx
Copy link

Oozyx commented Nov 6, 2024

Let's also add a second entrypoint and remove the proxy as sender check in transmit

@@ -524,17 +546,17 @@ contract DualAggregator is OCR2Abstract, OwnerIsCreator, AggregatorV2V3Interface

// decreasing loop from the latest primary round id
for (uint32 round_ = latestAggregatorRoundId; round_ > 0; --round_) {
// in case it's the latest secondary round id, return it
if (round_ == s_hotVars.latestSecondaryRoundId || latestAggregatorRoundId - round_ == s_maxSyncIterations) {
Copy link

Choose a reason for hiding this comment

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

Small gas optimization: store s_maxSyncIterations in a variable above the for loop and use that variable instead.

Copy link

Choose a reason for hiding this comment

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

Also this isn't correct. If it reaches the max iterations without having found the round, we shouldn't return anything. We should revert.

Copy link

Choose a reason for hiding this comment

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

We should also add a test case that covers exceeded the max iterations

Copy link
Author

@eduard-cl eduard-cl Nov 8, 2024

Choose a reason for hiding this comment

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

Not sure about reverting it, this internal function is called from all the get and latest methods.

Reverting it we make them all inaccessible and we can break many client applications.

I would simply have it to stop the loop, just like we have the cutoff time or the comparison with the latestSecondaryRoundId.

Copy link
Author

@eduard-cl eduard-cl Nov 8, 2024

Choose a reason for hiding this comment

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

Also, I'm not sure if it's really useful, since we already have the cutoff time to stop the loop, the maxIterations should always be bigger than the cutoff time, if not we would be returning a newer price than the cutoff time.

The only two cases I see:

  1. cutoffTime > maxIterations -> maxIterations has no effect to the loop.
  2. cutoffTime < maxIterations -> if we need the maxIterations, this means that the cutoffTime is too big and we should reduce it (also, we would be returning a newer round than the cutoff time).

Copy link

Choose a reason for hiding this comment

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

It's a valid point. The only purpose of the maxIterations variable would be so that we don't ever run into an out of gas error. As you mentioned, this would only happen if we have a very large cutoff time, and the secondary feed has been down for a long time.

But we should still have defined behaviour for those cases.

I just realized we have 2 helper functions that loop through rounds:

  1. _doesReportExist (called when writing)
  2. _getSyncPrimaryRound (called when reading)

For reading, if we reach maxIterations then returning latestSecondaryRoundId is the behaviour we want.

For writing, I believe if we reach maxIterations we should revert.

@Oozyx Oozyx marked this pull request as ready for review November 8, 2024 19:28
@Oozyx Oozyx requested a review from a team as a code owner November 8, 2024 19:28
@Oozyx Oozyx merged commit 754ec65 into feeds-project-develop Nov 8, 2024
67 of 86 checks passed
@Oozyx Oozyx deleted the transmit-function branch November 8, 2024 19:29
@cl-sonarqube-production
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

// check if this round does not accomplish the cutoff time condition
if (transmission.recordedTimestamp + s_cutoffTime < block.timestamp) {
// in case it's the latest secondary round id, return it
if (round_ == s_hotVars.latestSecondaryRoundId || latestAggregatorRoundId - round_ == maxIterations) {
Copy link

Choose a reason for hiding this comment

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

Isn't the second condition excluded by the previous if?

Copy link
Author

Choose a reason for hiding this comment

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

You're correct, I fixed it in this PR.

Report memory report_ = _decodeReport(report); // Decode the report

if (isSecondary) {
(bool exist, uint32 roundId) = _doesReportExist(report_);
Copy link

Choose a reason for hiding this comment

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

Wouldn't it be easier and cheaper to keep s_hotVars.latestEpochAndRoundSecondary for rejecting stale reports?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, as I already see you found, we implemented this in the Check round ids PR.

// get the latest round ids
uint32 latestAggregatorRoundId = s_hotVars.latestAggregatorRoundId;
uint32 latestSecondaryRoundId = s_hotVars.latestSecondaryRoundId;

// check if the message sender is the secondary proxy
if (msg.sender == s_secondaryProxy) {
Copy link

Choose a reason for hiding this comment

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

That's outdated, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants