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: use registered API keys in Candid-RPC methods #90

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

rvanasa
Copy link
Collaborator

@rvanasa rvanasa commented Nov 21, 2023

This PR changes the Candid-RPC methods to use registered RpcProvider API keys (previously only used for generic JSON-RPC requests).

Resolves #73.

@rvanasa rvanasa changed the title feat: pass API keys to Candid-RPC methods feat: use registered API keys in Candid-RPC methods Nov 21, 2023
json,
max_response_bytes,
async fn http_request(
_provider: &RpcNodeProvider,
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 the provider ignored?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The provider param will eventually be used for logging. For context, the http_request() method was originally added to enable mock HTTP outcalls in unit tests, but I removed this in favor of using state machine tests.

let providers = providers.borrow();
Some(
providers
.iter()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be more efficient to use a hash map rather than iterating through the whole list (possibly twice)?

Copy link
Collaborator Author

@rvanasa rvanasa Nov 22, 2023

Choose a reason for hiding this comment

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

Currently feels like a premature optimization (expecting maybe 10 providers overall), but it would make sense to eventually use a HashMap. I will definitely keep this in mind.

@rvanasa rvanasa merged commit ac6aa32 into main Nov 22, 2023
@rvanasa rvanasa deleted the candid-rpc-api-keys branch November 22, 2023 18:22
ETH_MAINNET_CHAIN_ID,
match provider {
EthereumProvider::Ankr => "rpc.ankr.com",
EthereumProvider::BlockPi => "ethereum.blockpi.network",
Copy link
Member

Choose a reason for hiding this comment

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

FYI @rvanasa : We are going to kick out BlockPi on the used providers for ckETH because it (without API keys) it has a hard limit of 25kB on the response size of any request that was problematic for us (eth_getLogs)

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.

Pass API keys to shared ckETH codebase
3 participants