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

yield_resume: add more integration tests #11287

Merged
merged 16 commits into from May 13, 2024

Conversation

saketh-are
Copy link
Collaborator

@saketh-are saketh-are commented May 10, 2024

This PR adds several unit tests covering different scenarios for yield timeout delivery.

There is also a minor bugfix for the case in which yield_resume is invoked in the same chunk in which the timeout is processed.

Copy link

codecov bot commented May 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.00%. Comparing base (657aa11) to head (25229fc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11287      +/-   ##
==========================================
+ Coverage   70.99%   71.00%   +0.01%     
==========================================
  Files         781      781              
  Lines      155507   155507              
  Branches   155507   155507              
==========================================
+ Hits       110400   110420      +20     
+ Misses      40330    40316      -14     
+ Partials     4777     4771       -6     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (ø)
db-migration 0.24% <0.00%> (ø)
genesis-check 1.40% <0.00%> (ø)
integration-tests 37.22% <100.00%> (+0.09%) ⬆️
linux 69.05% <100.00%> (+<0.01%) ⬆️
linux-nightly 70.48% <100.00%> (+0.02%) ⬆️
macos 50.81% <100.00%> (-1.63%) ⬇️
pytests 1.62% <0.00%> (ø)
sanity-checks 1.42% <0.00%> (ø)
unittests 65.42% <100.00%> (+<0.01%) ⬆️
upgradability 0.29% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@saketh-are saketh-are requested a review from nagisa May 12, 2024 23:14
@saketh-are saketh-are marked this pull request as ready for review May 12, 2024 23:14
@saketh-are saketh-are requested a review from a team as a code owner May 12, 2024 23:14
runtime/runtime/src/lib.rs Show resolved Hide resolved

let mut tx_hashes = vec![];

for i in 0..25 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there not a good way to avoid hardcoding the number of transactions here? I feel like this test might lose its behaviour if the compute costs are reduced in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately I couldn't think of a way to congest the chain which doesn't involve specifying some fixed number of transactions greater than 1.

);

// Allow two blocks for the function call to be executed
for i in 3..5 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for i in 3..5 {
for i in 3..NEXT_BLOCK_HEIGHT_AFTER_SETUP {

perhaps? I would also introduce a variable for the 3. An assert that the variabl does not exceed the constant wouldn't hurt either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I simply added a check at the end of prepare_env which gets the height of the head of the chain from one of the test clients and compares with NEXT_BLOCK_HEIGHT_AFTER_SETUP.

I think changing these constants to variables doesn't achieve much:

  • It obfuscates what the loop wants to do (advance two blocks)
  • The height 3 is never referenced outside the prepare_env function

}

/// In this test we introduce congestion to delay the yield timeout so that we can invoke
/// yield resume after the timeout height has passed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We look for the invocation of the continuation function here, and not a transaction with the yield_resume host function after the timeout has occurred, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we verify that both things occur.

The transaction invoking yield_create during env setup uses promise_return so that its final outcome is whatever the continuation function returns. The continuation function returns an indicator of whether it was invoked by timeout or with a user payload. At the end of the test we verify that the original transaction has the right outcome.

@saketh-are saketh-are enabled auto-merge May 13, 2024 16:04
@saketh-are saketh-are added this pull request to the merge queue May 13, 2024
Merged via the queue into near:master with commit 9e7acee May 13, 2024
28 of 29 checks passed
@saketh-are saketh-are deleted the yield-timeout-tests branch May 13, 2024 16:44
posvyatokum pushed a commit that referenced this pull request May 15, 2024
This PR adds several unit tests covering different scenarios for yield
timeout delivery.

There is also a minor bugfix for the case in which yield_resume is
invoked in the same chunk in which the timeout is processed.
nagisa pushed a commit to nagisa/nearcore that referenced this pull request May 15, 2024
This PR adds several unit tests covering different scenarios for yield
timeout delivery.

There is also a minor bugfix for the case in which yield_resume is
invoked in the same chunk in which the timeout is processed.
posvyatokum added a commit that referenced this pull request May 15, 2024
posvyatokum pushed a commit that referenced this pull request May 15, 2024
This PR adds several unit tests covering different scenarios for yield
timeout delivery.

There is also a minor bugfix for the case in which yield_resume is
invoked in the same chunk in which the timeout is processed.
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.

None yet

3 participants