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

fix: prevent processor from attempting to run an empty select_all #211

Merged
merged 5 commits into from
Jul 14, 2022

Conversation

prestwich
Copy link
Member

@prestwich prestwich commented Jul 14, 2022

Motivation

Processor was encountering a panic when running with only an ethereum remote

Message:  assertion failed: !ret.inner.is_empty()
Location: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.21/src/future/select_all.rs:40
  • the error occurs because futures_util::select_all is invoked with an empty vector.

  • the only place where this could occur in our code is in NomadAgent::run_many which calls select_all on the result of an iterator

    • grep -ri --include="*.rs" "select_all" * will identify locations where select_all is invoked
  • this iterator may only be empty if the names slice is empty when called

  • NomadAgent::run_many is invoked from NomadAgent::run_all

  • it is also invoked from <Processor as **NomadAgent>::run_all overriding the default trait impl

  • the <Processor as NomadAgent>::run_all would run certain tasks ONLY for subsidized networks

  • it would do this by loading the subsidized_networks and calculating the intersection with remote_networks, and making a task for each network in the intersection

  • this would result in an empty task vector if no subsidized networks were specified in remote_networks

Solution

  • Adds checks that replica is non-empty to the default implementations of NomadAgent::run_all and NomadAgent::run_many
  • Add check that specified_subsidized is not empty when running select_all in <Processor as NomadAgent>::run_all
  • Filter subsidized_remotes by inclusion in remote_networks to prevent similar errors in the future

PR Checklist

  • Added Tests
  • Updated Documentation
  • Updated CHANGELOG.md for the appropriate package

@prestwich prestwich added bug Something isn't working fix labels Jul 14, 2022
@prestwich prestwich self-assigned this Jul 14, 2022
@prestwich prestwich changed the title feature: check that replicas is non-empty fix: prevent processor from attemtping to run an empty select_all Jul 14, 2022
@prestwich prestwich changed the title fix: prevent processor from attemtping to run an empty select_all fix: prevent processor from attempting to run an empty select_all Jul 14, 2022
@prestwich prestwich marked this pull request as ready for review July 14, 2022 01:51
Copy link
Collaborator

@luketchang luketchang left a comment

Choose a reason for hiding this comment

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

Can delete some redundant checks but other than that LGTM, thanks for fixing my bug

agents/processor/src/processor.rs Show resolved Hide resolved
@prestwich prestwich enabled auto-merge (squash) July 14, 2022 16:22
@prestwich prestwich merged commit 7e1dc8b into main Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants