Skip to content

Integration test for attestations #413

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

Merged
merged 11 commits into from
Dec 6, 2022
Merged

Integration test for attestations #413

merged 11 commits into from
Dec 6, 2022

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Dec 5, 2022

This PR adds a new job to tilt that checks that all symbols being published are also being attested. I tweaked some things on the publisher http endpoint to ensure that the check only succeeds once all of the dynamically-added symbols are generated. I also tweaked the configuration there to make tilt complete a little faster.

@jayantk jayantk changed the title integration test ??? [wip] integration test ??? Dec 5, 2022
@@ -167,7 +154,7 @@
cfg_yaml += f"""
- group_name: longer_interval_sensitive_changes
conditions:
min_interval_secs: 10
min_interval_secs: 3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

attest faster so we don't have to wait as long for the checking to work

@@ -17,14 +20,15 @@
# How long to sleep between mock Pyth price updates
PYTH_PUBLISHER_INTERVAL_SECS = float(os.environ.get("PYTH_PUBLISHER_INTERVAL_SECS", "5"))
PYTH_TEST_SYMBOL_COUNT = int(os.environ.get("PYTH_TEST_SYMBOL_COUNT", "11"))
PYTH_DYNAMIC_SYMBOL_COUNT = int(os.environ.get("PYTH_DYNAMIC_SYMBOL_COUNT", "2"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

both of the changes here are again to make the attestation checking complete more quickly

@jayantk jayantk changed the title [wip] integration test ??? Integration test for attestations Dec 5, 2022

# If above 0, adds a new test symbol periodically, waiting at least
# the given number of seconds in between
#
# NOTE: the new symbols are added in the HTTP endpoint used by the
# p2w-attest service in Tilt. You may need to wait to see p2w-attest
# pick up brand new symbols
PYTH_NEW_SYMBOL_INTERVAL_SECS = int(os.environ.get("PYTH_NEW_SYMBOL_INTERVAL_SECS", "120"))
PYTH_NEW_SYMBOL_INTERVAL_SECS = int(os.environ.get("PYTH_NEW_SYMBOL_INTERVAL_SECS", "60"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mind making it 30 seconds? To be even faster?

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.

Very nice!

Copy link
Contributor

@drozdziak1 drozdziak1 left a comment

Choose a reason for hiding this comment

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

Lookin' good! I'm not feeling strongly about those comments, but I'd love to see some of them applied.

spec:
clusterIP: None
selector:
app: p2w-attest
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should also be "check-attestations"


# Where to read the set of accounts from
PYTH_TEST_ACCOUNTS_HOST = "pyth"
PYTH_TEST_ACCOUNTS_PORT = 4242
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should live in pyth_utils.py and be used by both this and pyth_publisher.py, but it's probably fine

@@ -108,6 +111,20 @@ def sol_run_or_die(subcommand, args=[], **kwargs):
return run_or_die(["solana", subcommand] + args + ["--url", SOL_RPC_URL], **kwargs)


def get_json(host, path, port):
Copy link
Contributor

Choose a reason for hiding this comment

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

reorder to host, port, path?

@@ -31,7 +31,7 @@ def do_GET(self):
self.wfile.flush()

# Test publisher state that gets served via the HTTP endpoint. Note: the schema of this dict is extended here and there
HTTP_ENDPOINT_DATA = {"symbols": [], "mapping_address": None}
HTTP_ENDPOINT_DATA = {"symbols": [], "mapping_address": None, "all_symbols_added": False}
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, all_symbols_added makes the check-attestations dependency on pyth a special case. It is special, because an additional decision of the mock publisher logic permits check-attestations to go green.

I think that's reasonable, but can you note here what this is for?

else:
logging.info("Price ids match but still waiting for more symbols to come online.")
else:
logging.info("Price ids do not match")
Copy link
Contributor

@drozdziak1 drozdziak1 Dec 6, 2022

Choose a reason for hiding this comment

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

I think making if all_symbols_added the outermost test could be useful here. Inside we could do just a single config comparison and fail the whole script on mismatch. The publisher has a very well defined state when it's done adding symbols. This means that the expected attester state is also well defined and should be reached soon. The way this is handled now, it will be just a readiness timeout, which means a delay before any problems are reported. With this, failure of the python process would be visible as soon as it occurs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can't fail here because there's a race condition between the attester and the HTTP endpoint which can cause this case to trigger (but the next loop iteration succeeds). Looping is more reliable.

Copy link
Contributor

Choose a reason for hiding this comment

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

that makes sense

@@ -164,6 +164,9 @@ def add_symbol(num: int):
next_new_symbol_id += 1
dynamically_added_symbols += 1

if dynamically_added_symbols >= PYTH_DYNAMIC_SYMBOL_COUNT:
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally like the permissive comparison, but I think the > case would be a bug in this script, maybe we could yell about it and only be quiet for ==?

@jayantk jayantk merged commit a3199b7 into main Dec 6, 2022
@jayantk jayantk deleted the check-attestations branch December 6, 2022 17:57
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.

3 participants