-
Notifications
You must be signed in to change notification settings - Fork 97
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: fetch node keys from subnet certificate #776
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be13d95
wip
krpeacock 135ff50
working certificate subnet node keys
krpeacock 23ba754
cleaning up
krpeacock 1d8852a
adding certificate node caching tests
krpeacock 6634162
fixing canisterStatus test for extra call
krpeacock ca980c0
tests passing
krpeacock ca8a33f
cleaning up lookup, changelog
krpeacock 6cad1c3
more cleanup
krpeacock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/agent/src/agent/http/__certificates__/goldenCertificates.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
/** @module CanisterStatus */ | ||
|
||
import { Principal } from '@dfinity/principal'; | ||
import { AgentError } from '../errors'; | ||
import { HttpAgent } from '../agent/http'; | ||
import { Certificate, CreateCertificateOptions } from '../certificate'; | ||
import { | ||
Certificate, | ||
CreateCertificateOptions, | ||
SubnetStatus, | ||
lookupResultToBuffer, | ||
} from '../certificate'; | ||
import { toHex } from '../utils/buffer'; | ||
import * as Cbor from '../cbor'; | ||
import { decodeLeb128, decodeTime } from '../utils/leb'; | ||
|
@@ -12,7 +16,15 @@ import { decodeLeb128, decodeTime } from '../utils/leb'; | |
* Types of an entry on the canisterStatus map. | ||
* An entry of null indicates that the request failed, due to lack of permissions or the result being missing. | ||
*/ | ||
export type Status = string | ArrayBuffer | Date | ArrayBuffer[] | Principal[] | bigint | null; | ||
export type Status = | ||
| string | ||
| ArrayBuffer | ||
| Date | ||
| ArrayBuffer[] | ||
| Principal[] | ||
| SubnetStatus | ||
| bigint | ||
| null; | ||
|
||
/** | ||
* Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using {@link TextEncoder} | ||
|
@@ -98,7 +110,24 @@ export const request = async (options: { | |
canisterId: canisterId, | ||
}); | ||
|
||
const data = cert.lookup(encodePath(uniquePaths[index], canisterId)); | ||
response.certificate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a leftover? |
||
const lookup = (cert: Certificate, path: Path) => { | ||
if (path === 'subnet') { | ||
const data = cert.cache_node_keys(); | ||
return { | ||
path: path, | ||
data, | ||
}; | ||
} else { | ||
return { | ||
path: path, | ||
data: lookupResultToBuffer(cert.lookup(encodePath(path, canisterId))), | ||
}; | ||
} | ||
}; | ||
|
||
// must pass in the rootKey if we have no delegation | ||
const { path, data } = lookup(cert, uniquePaths[index]); | ||
if (!data) { | ||
// Typically, the cert lookup will throw | ||
console.warn(`Expected to find result for path ${path}, but instead found nothing.`); | ||
|
@@ -121,6 +150,10 @@ export const request = async (options: { | |
status.set(path, decodeHex(data)); | ||
break; | ||
} | ||
case 'subnet': { | ||
status.set(path, data); | ||
break; | ||
} | ||
case 'candid': { | ||
status.set(path, new TextDecoder().decode(data)); | ||
break; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these like the golden tickets in willy wonka?