Skip to content

Conversation

@Reisen
Copy link
Contributor

@Reisen Reisen commented Feb 21, 2022

This PR includes only commits required to merge aggregation logic into the Pyth contract, these have been spliced out from #139 with only the required utilities for aggregation. This doesn't include utilities that aren't used as they can be included in future PRs.

@ali-behjati
Copy link
Collaborator

Shall we update the tests before review?

pyth/tests/qset tests are failing, those are ran with pctest/test_qset.cpp to interact with the contract and return the result of update aggregate.

Also we should double check the test_oracle tests

Copy link
Contributor

@jayantk jayantk left a comment

Choose a reason for hiding this comment

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

ok i read through this carefully and it largely makes sense. left a couple comments. would really prefer to address anything nontrivial in a separate PR though. will follow up on slack to figure out the best next steps.

/* Brute force validate small sizes via the 0-1 principle (with
additional information in the keys to validate stability as well). */

for( int n=0; n<=24; n++ ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this could really use a comment describing how the entries of x[i] are bitpacked.


int * z = sort_stable( x,n, y );

/* Make sure that z is a permutation of input data */
Copy link
Contributor

Choose a reason for hiding this comment

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

this code block is duplicated. could extract this out to a function that is called here and above.

}

// too few valid quotes
ptr->num_qt_ = numv; // FIXME: TEMPORARY GRAFT (ALL RETURN PATHS SET NUM_QT TO SOMETHING SENSIBLE)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this temporary? seems like if we delete the old aggregation logic, this should still be set here?

// CONDENSED AND/OR MADE MORE EFFICIENT. AND IT PROBABLY WILL
// REPLACED SOON BY THE VWAP MODEL UNDER DEVELOPMENT. IT IS KEPT HERE
// TO KEEP THE CURRENT VWAP CALCULATION AS CLOSE AS POSSIBLE TO WHAT
// HOW IT CURRENTLY WORKS.
Copy link
Contributor

Choose a reason for hiding this comment

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

let's actually do this comment and delete the old price model from below. we can keep the old twap computation and feed the new aggregate price / confidence into it. I believe most of the code below is dead.

Copy link
Contributor

@jayantk jayantk left a comment

Choose a reason for hiding this comment

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

LGTM. We decided to put this in a separate branch (so we can hotfix main if necessary), so I think you can push this to a branch called v2 and we can start sending PRs against that.

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

I read through the unused previous logic, I think it is safe to remove them. Let's discuss it.

// too few valid quotes
ptr->num_qt_ = numv; // FIXME: TEMPORARY GRAFT (ALL RETURN PATHS SET NUM_QT TO SOMETHING SENSIBLE)
if ( numv == 0 || numv < ptr->min_pub_ ) {
ptr->agg_.status_ = PC_STATUS_UNKNOWN;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want this behavior to happen here?

My expectation was that even if number of publishers is less min_pub we still process the price but set the status to unknown. Here it only changes the status and does not calculate the price.

for( ; j > 0 && ptr->comp_[ aidx[ j - 1 ] ].agg_.price_ > prc; --j ) { // FIXME: O(N^2)
aidx[ j ] = aidx[ j - 1 ];
}
aidx[ j ] = idx;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Few lines below (line below // zero quoters) It sets number of publishers to something other than what we like: publishers with price between [agg_price/5, agg_price*5]

@Reisen
Copy link
Contributor Author

Reisen commented Mar 2, 2022

Pushed as branch v2, so no merge required. New aggregation PR's can be made against v2.

@Reisen Reisen closed this Mar 2, 2022
guibescos pushed a commit that referenced this pull request Aug 2, 2022
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.

5 participants