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

user and replica set entity manager #3897

Merged
merged 40 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
daa65bc
add user entity manager
Aug 24, 2022
a2ff380
Update discovery user replica route and entity manager
jowlee Sep 20, 2022
abcd2f1
WIP CN check discovery vs chain
jowlee Sep 20, 2022
226f990
Update libs bindings for entity manager
jowlee Sep 20, 2022
f3d146b
lint discovery
jowlee Sep 20, 2022
bb3cf8f
Fix lint
isaacsolo Sep 20, 2022
9f712af
Turn on dev features
jowlee Sep 20, 2022
41d62d6
removediscovery logs
jowlee Sep 20, 2022
6ff89b4
Add wait for discovery indexing to cn replica set update
jowlee Sep 20, 2022
62cbca4
Fix libs type
jowlee Sep 20, 2022
124efa0
Fix lint
jowlee Sep 20, 2022
2cfe98a
fix api unit test
isaacsolo Sep 20, 2022
6df44fd
Update ns docs for api change
jowlee Sep 20, 2022
7d2ad97
Update gen types
jowlee Sep 20, 2022
8a9a2bf
FIx cn tests
jowlee Sep 21, 2022
fc0deac
Update sdk api
jowlee Sep 21, 2022
61b8686
Update user replica endpoint to return empty when not found
jowlee Sep 23, 2022
0007140
Address comments on cn middleware ensure primary
jowlee Sep 23, 2022
c02f193
Update libs to return err on discovery blocknumber makereq
jowlee Sep 23, 2022
bcc5bab
Put content entity manager and discovery validation behind env var
jowlee Sep 23, 2022
8185a26
Fix discovery lint
jowlee Sep 23, 2022
3678b38
Update creator node
jowlee Sep 26, 2022
432502f
Fix discovery indexing
jowlee Sep 26, 2022
f5d6606
fix libs
jowlee Sep 26, 2022
d93c12c
lint fix discovery
jowlee Sep 26, 2022
c4a27e8
add more entity manager flags and fix bugs w updates
isaacsolo Sep 26, 2022
fcc0ade
update entityManagerAddress in CN config and add handle_lc
isaacsolo Sep 26, 2022
4a838ba
fix types
isaacsolo Sep 27, 2022
b30e79b
Update local cn entity manager addr
jowlee Sep 27, 2022
10f976e
Add timeout to get user replica set
jowlee Sep 27, 2022
3b76a13
Update local env vs prod config for entity manager
jowlee Sep 27, 2022
2ddbf89
Address comments
jowlee Sep 28, 2022
db8523f
Merge branch 'master' into jowlee-user-entity-manager
jowlee Sep 28, 2022
47cc666
Fix merge err
jowlee Sep 28, 2022
536941c
Fix libs bug
jowlee Sep 28, 2022
2de10b3
fix libs lint
jowlee Sep 28, 2022
eaec22f
add comment on wait for repica set indexing
jowlee Sep 28, 2022
61f3516
Merge branch 'master' into jowlee-user-entity-manager
jowlee Sep 28, 2022
a032582
lint fix discovery after merge
jowlee Sep 28, 2022
af07a88
Fix metadata change test
jowlee Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions libs/src/api/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export class Users extends Base {
spIds.join(',')
)

await this.waitForReplicaSetDiscoveryIndexing(
await this.waitForReplicaSetDiscoveryIndexing(
userId,
spIds,
manageEntityResponse.txReceipt.blockNumber
Expand Down Expand Up @@ -993,36 +993,44 @@ export class Users extends Base {
}
}

/**
* Waits for the input replica set to be indexed by the discovery node
* If then replica set matches at the requested block number -> return null
* If the replica set response is null at the block number -> throw error
* If the replica set is mismatched at the block number -> throw error
* If the timeout is exceeded before replica set indexed -> throw error
*/
async waitForReplicaSetDiscoveryIndexing(
SidSethi marked this conversation as resolved.
Show resolved Hide resolved
userId: number,
replicaSetSPIDs: number[],
blockNumber: number,
timeoutMs = 60000
) {
): Promise<void> {
const asyncFn = async () => {
while (true) {
const encodedUserId = Utils.encodeHashId(userId)
let replicaSet
try {
jowlee marked this conversation as resolved.
Show resolved Hide resolved
const replicaSet = await this.discoveryProvider.getUserReplicaSet({
replicaSet = await this.discoveryProvider.getUserReplicaSet({
encodedUserId: encodedUserId!,
blockNumber
})
if (replicaSet) {
if (
replicaSet.primarySpID === replicaSetSPIDs[0] &&
replicaSet.secondary1SpID === replicaSetSPIDs[1] &&
replicaSet.secondary2SpID === replicaSetSPIDs[2]
) {
break
} else {
throw new Error(
`[User:waitForReplicaSetDiscoveryIndexing()] Indexed block ${blockNumber}, but did not find matching sp ids`
)
}
}
} catch (err) {
// Do nothing on error
}
if (replicaSet) {
if (
replicaSet.primarySpID === replicaSetSPIDs[0] &&
replicaSet.secondary1SpID === replicaSetSPIDs[1] &&
replicaSet.secondary2SpID === replicaSetSPIDs[2]
) {
break
} else {
throw new Error(
`[User:waitForReplicaSetDiscoveryIndexing()] Indexed block ${blockNumber}, but did not find matching sp ids`
)
}
}
await Utils.wait(500)
jowlee marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/src/services/discoveryProvider/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ export const verifyToken = (token: string) => {

export const getUserReplicaSet = (encodedUserId: string) => {
return {
endpoint: `/v1/users/${encodedUserId}/replica_set`,
endpoint: `/v1/full/users/${encodedUserId}/replica_set`,
timeout: 5000
}
}