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

[core] user state db #552

Open
vivianjeng opened this issue Oct 5, 2023 · 0 comments · May be fixed by #577
Open

[core] user state db #552

vivianjeng opened this issue Oct 5, 2023 · 0 comments · May be fixed by #577
Labels
enhancement New feature or request

Comments

@vivianjeng
Copy link
Member

vivianjeng commented Oct 5, 2023

User can have his db to store related data
e.g.

data type description
attesterId String the attester ID
latestTransitionedEpoch Int the schema is created at which epoch
latestTransitionedIndex Int in this epoch, the index of the user in the state tree
provableData Object the data in the state tree
latestData Object the data in the current epoch

so the user doesn't have to search through all epochs

for (let x = signup?.epoch ?? 0; x <= toEpoch; x++) {
allNullifiers.push(
...[0, this.sync.settings.numEpochKeyNoncePerEpoch].map((v) =>
genEpochKey(
this.id.secret,
attesterId,
x,
v,
this.chainId
).toString()
)
)
}
const sortedNullifiers = await this.sync.db.findMany('Nullifier', {
where: {
attesterId,

Details

original getData

epoch data 1 data 2 data 3 data 4
0 0 0 1 0
1 0 0 0 1
2 1 0 0 0
3 0 1 0 0
... ... ... ... ...
total 1 1 1 1

proposed db

If there is no db, then use original getData to get the latest data

name data
provable data [1,1,1, 1]
latest transition epoch 3

new epoch original getData

epoch data 1 data 2 data 3 data 4
0 0 0 1 0
1 0 0 0 1
2 1 0 0 0
3 0 1 0 0
4 1 1 1 1
... ... ... ... ...
total 2 2 2 2

new epoch proposed db

If there is a db, then new data is updated by
db.provableData = db.provableData + newData
[2,2,2,2] = [1,1,1,1] + [1,1,1,1]

name data
provable data [2,2,2, 2]
latest transition epoch 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant