PocketIC does not check for http outcalls reaching consensus
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 204
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The following code runs perfectly on local network dfx start but fails on mainnet:
const JWK_URL: &str =
"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com";
pub async fn fetch_public_keys() -> Result<JwkKeys, FetchPublicKeysError> {
let response =
ic_cdk::management_canister::http_request(&ic_cdk::management_canister::HttpRequestArgs {
url: JWK_URL.to_string(),
max_response_bytes: None,
method: ic_cdk::management_canister::HttpMethod::GET,
headers: vec![],
body: None,
transform: None,
})
.await
.map_err(FetchPublicKeysError::CouldntFetchPublicKeys)?;
// ...
}
The error: No consensus could be reached. Replicas had different responses.
I'm almost certain that the reason for this error is that HTTP response is different for each call to this URL (max-age header value changes). There's no way for such errors to be caught in development
Potential solution
PocketIC should try to make more than one HTTP call and compare response results, to better simulate the production environment. Just two calls would've caught the error for the aforementioned URL
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating PocketIC's handling of HTTP outcalls and review how a single response is currently returned. Reproduce the JWK URL scenario with repeated calls, then verify that differing responses are detected so local testing exposes the consensus failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100