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

feat: Add resource provider allowlist #481

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Jan 9, 2025

⚠️ Do not merge until we have merged the first solver database PR: #462

Summary

This pull request makes the following changes:

  • Add allowed resource provider store methods
  • Add memory method implementations
  • Add database method implementations
  • Add memory and database store tests
  • Add SERVER_ENABLE_RESOURCE_PROVIDER_ALLOWLIST config to enable/disable allowlist (defaults to false)
  • Check allowlist on POST /resource_offers handler when allowlist enabled

We are adding a resource provider allowlist to gate resource offers during our beta program.

Task/Issue reference

Closes: #479

Test plan

We have added a new set of tests for the memory and database implementations of the new allowed resource provider store methods.

To test the allowlist disabled configuration, start the base services, solver, and resource provider.

./stack compose-services
./stack solver

The resource provider should be able to post it's resource offer. Stop the solver and resource provider.

To test the allowlist enabled configuration, start the solver with the allowlist enabled:

./stack solver --server-enable-resource-provider-allowlist true

Start the resource provider:

./stack resource-provider

They will attempt to post their resource offer with retries and eventually fail with an error message:

POST http://localhost:8081/api/v1/resource_offers gave up after 11 attempt(s): resource provider not allowed to post resource offer 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65

Connect to the database with psql:

docker exec -it postgres psql -U postgres -d solver-db

Once in psql, insert your resource provider into the allowed_resource_providers table:

insert into allowed_resource_providers (resource_provider) values ('0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65');

Start the resource provider again and it should be able to post its resource offer.

Details

Configuration

The allowlist is enabled or disabled with a environment variable or CLI option:

./stack solver --server-enable-resource-provider-allowlist true
SERVER_ENABLE_RESOURCE_PROVIDER_ALLOWLIST=true ./stack solver 

The config name got crazy long, so open to suggestions for something shorter. 😄

Related issues or PRs

Epic: https://github.com/Lilypad-Tech/internal/issues/367

@cla-bot cla-bot bot added the cla-signed label Jan 9, 2025
@bgins bgins force-pushed the bgins/feat-add-rp-allowlist branch from 49c54a3 to d5673d2 Compare January 9, 2025 23:50
@bgins bgins changed the title Bgins/feat add rp allowlist feat: Add resource provider allowlist Jan 9, 2025
@bgins bgins force-pushed the bgins/feat-add-rp-allowlist branch from d5673d2 to 3a67aaa Compare January 10, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add resource provider allowlist
1 participant