mirror of
https://github.com/zkopru-network/zkopru.git
synced 2026-04-24 03:00:03 -04:00
fix(prisma): block structure
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build:prisma": "prisma generate",
|
||||
"postinstall": "lerna bootstrap && yarn build:fresh",
|
||||
"prep-containers": "make pull-dev-images",
|
||||
"bootstrap": "lerna bootstrap && lerna link --force-local",
|
||||
@@ -57,6 +58,7 @@
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^8.1.0",
|
||||
"@commitlint/config-conventional": "^8.1.0",
|
||||
"@prisma/cli": "^2.0.0-beta.8",
|
||||
"@truffle/artifactor": "^4.0.30",
|
||||
"@types/async-lock": "^1.1.1",
|
||||
"@types/cli-progress": "^3.7.0",
|
||||
@@ -71,6 +73,7 @@
|
||||
"@types/pino": "^6.0.0",
|
||||
"@types/prompts": "^2.0.8",
|
||||
"@types/tar": "^4.0.3",
|
||||
"@types/uuid": "^8.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.2.0",
|
||||
"@typescript-eslint/parser": "^2.2.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
@@ -120,7 +123,8 @@
|
||||
"tsconfig-paths": "^3.9.0",
|
||||
"typechain": "^1.0.5",
|
||||
"typechain-target-web3-v1": "^1.0.4",
|
||||
"typescript": "3.8.3"
|
||||
"typescript": "3.8.3",
|
||||
"uuid": "^8.1.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
"build:prisma": "prisma generate",
|
||||
"migrate-save": "prisma migrate save --experimental",
|
||||
"migrate-up": "prisma migrate up --experimental",
|
||||
"gen-mockup": "yarn migrate-save && yarn migrate-up",
|
||||
"prebuild": "shx mkdir -p dist",
|
||||
"build": "tsc --build tsconfig.build.json",
|
||||
"build": "yarn build:prisma && tsc --build tsconfig.build.json",
|
||||
"clean": "tsc --build tsconfig.build.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache",
|
||||
"link-modules": "link-module-alias",
|
||||
"test": "jest",
|
||||
@@ -44,6 +45,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@prisma/cli": "^2.0.0-beta.8",
|
||||
"@types/sqlite3": "^3.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,271 +0,0 @@
|
||||
# Migration `20200605150020-initial`
|
||||
|
||||
This migration has been generated by Wanseob Lim at 6/5/2020, 3:00:20 PM.
|
||||
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||
|
||||
## Database Steps
|
||||
|
||||
```sql
|
||||
PRAGMA foreign_keys=OFF;
|
||||
|
||||
CREATE TABLE "quaint"."EncryptedWallet" (
|
||||
"N" INTEGER NOT NULL ,"algorithm" TEXT NOT NULL ,"ciphertext" TEXT NOT NULL ,"id" TEXT NOT NULL ,"iv" TEXT NOT NULL ,"kdf" TEXT NOT NULL ,"keylen" INTEGER NOT NULL ,"p" INTEGER NOT NULL ,"r" INTEGER NOT NULL ,"salt" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"))
|
||||
|
||||
CREATE TABLE "quaint"."Keystore" (
|
||||
"address" TEXT NOT NULL ,"encrypted" TEXT NOT NULL ,"pubKey" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("address"))
|
||||
|
||||
CREATE TABLE "quaint"."Config" (
|
||||
"address" TEXT NOT NULL ,"chainId" INTEGER NOT NULL ,"challengePeriod" INTEGER NOT NULL ,"id" TEXT NOT NULL ,"maxUtxoPerTree" TEXT NOT NULL ,"maxWithdrawalPerTree" TEXT NOT NULL ,"minimumStake" TEXT NOT NULL ,"networkId" INTEGER NOT NULL ,"nullifierTreeDepth" INTEGER NOT NULL ,"referenceDepth" INTEGER NOT NULL ,"txoTreeDepth" INTEGER NOT NULL ,"utxoSubTreeDepth" INTEGER NOT NULL ,"utxoSubTreeSize" INTEGER NOT NULL ,"withdrawalSubTreeDepth" INTEGER NOT NULL ,"withdrawalSubTreeSize" INTEGER NOT NULL ,"withdrawalTreeDepth" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("id") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."ZkOPRUChain" (
|
||||
"id" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"))
|
||||
|
||||
CREATE TABLE "quaint"."Block" (
|
||||
"chainId" TEXT ,"hash" TEXT NOT NULL ,"proposalData" TEXT NOT NULL ,"proposalNum" INTEGER NOT NULL ,"proposalTx" TEXT NOT NULL ,"proposedAt" INTEGER NOT NULL ,"status" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("hash"),FOREIGN KEY ("hash") REFERENCES "Header"("hash") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY ("hash") REFERENCES "Bootstrap"("hash") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY ("chainId") REFERENCES "ZkOPRUChain"("id") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Header" (
|
||||
"challengePeriod" INTEGER NOT NULL ,"hash" TEXT NOT NULL ,"maxUtxoPerTree" TEXT NOT NULL ,"maxWithdrawalPerTree" TEXT NOT NULL ,"minimumStake" TEXT NOT NULL ,"nullifierTreeDepth" INTEGER NOT NULL ,"referenceDepth" INTEGER NOT NULL ,"txoTreeDepth" INTEGER NOT NULL ,"utxoSubTreeDepth" INTEGER NOT NULL ,"utxoSubTreeSize" INTEGER NOT NULL ,"withdrawalSubTreeDepth" INTEGER NOT NULL ,"withdrawalSubTreeSize" INTEGER NOT NULL ,"withdrawalTreeDepth" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("hash"))
|
||||
|
||||
CREATE TABLE "quaint"."Bootstrap" (
|
||||
"hash" TEXT NOT NULL ,"utxoBootstrap" TEXT NOT NULL ,"utxoTreeIndex" INTEGER NOT NULL ,"withdrawalBootstrap" TEXT NOT NULL ,"withdrawalTreeIndex" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("hash"))
|
||||
|
||||
CREATE TABLE "quaint"."MassDeposit" (
|
||||
"blockNumber" INTEGER NOT NULL ,"fee" TEXT NOT NULL ,"includedIn" TEXT ,"index" TEXT NOT NULL ,"merged" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("index"),FOREIGN KEY ("includedIn") REFERENCES "Block"("hash") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Deposit" (
|
||||
"blockNumber" INTEGER NOT NULL ,"fee" TEXT NOT NULL ,"includedIn" TEXT ,"logIndex" INTEGER NOT NULL ,"note" TEXT NOT NULL ,"queuedAt" TEXT ,"transactionIndex" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("note"),FOREIGN KEY ("queuedAt") REFERENCES "MassDeposit"("index") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Nullifier" (
|
||||
"blockHash" TEXT NOT NULL ,"index" TEXT NOT NULL ,"nullified" BOOLEAN NOT NULL ,
|
||||
PRIMARY KEY ("index"))
|
||||
|
||||
CREATE TABLE "quaint"."Note" (
|
||||
"erc20Amount" TEXT ,"eth" TEXT ,"fee" TEXT ,"hash" TEXT NOT NULL ,"index" TEXT ,"nft" TEXT ,"pubKey" TEXT ,"salt" TEXT ,"status" INTEGER ,"tokenAddr" TEXT ,"treeId" TEXT ,"type" INTEGER ,"withdrawOutTo" TEXT ,
|
||||
PRIMARY KEY ("hash"),FOREIGN KEY ("treeId") REFERENCES "LightTree"("id") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."TreeNode" (
|
||||
"nodeIndex" TEXT NOT NULL ,"treeId" TEXT NOT NULL ,"value" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("treeId","nodeIndex"))
|
||||
|
||||
CREATE TABLE "quaint"."LightTree" (
|
||||
"block" TEXT ,"end" TEXT NOT NULL ,"id" TEXT NOT NULL ,"index" TEXT NOT NULL ,"root" TEXT NOT NULL ,"siblings" TEXT NOT NULL ,"species" INTEGER NOT NULL ,"start" TEXT NOT NULL ,"treeIndex" INTEGER NOT NULL ,"zkopru" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("zkopru") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."NullifierTree" (
|
||||
"block" TEXT ,"id" TEXT NOT NULL ,"root" TEXT NOT NULL ,"siblings" TEXT NOT NULL ,"treeIndex" INTEGER NOT NULL ,"zkopru" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("zkopru") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."Config_id" ON "Config"("id")
|
||||
|
||||
CREATE INDEX "quaint"."LightTree.species_treeIndex" ON "LightTree"("species","treeIndex")
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."NullifierTree.treeIndex" ON "NullifierTree"("treeIndex")
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."NullifierTree_zkopru" ON "NullifierTree"("zkopru")
|
||||
|
||||
PRAGMA "quaint".foreign_key_check;
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
```
|
||||
|
||||
## Changes
|
||||
|
||||
```diff
|
||||
diff --git schema.prisma schema.prisma
|
||||
migration ..20200605150020-initial
|
||||
--- datamodel.dml
|
||||
+++ datamodel.dml
|
||||
@@ -1,0 +1,179 @@
|
||||
+generator client {
|
||||
+ provider = "prisma-client-js"
|
||||
+}
|
||||
+
|
||||
+datasource sqlite {
|
||||
+ provider = "sqlite"
|
||||
+ url = env("DATABASE_URL")
|
||||
+}
|
||||
+
|
||||
+// datasource posgres {
|
||||
+// provider = "postgres"
|
||||
+// url = env("POSTGRES_URL")
|
||||
+// }
|
||||
+
|
||||
+model EncryptedWallet {
|
||||
+ id String @id @default(uuid())
|
||||
+ ciphertext String
|
||||
+ iv String
|
||||
+ algorithm String
|
||||
+ keylen Int
|
||||
+ kdf String
|
||||
+ N Int
|
||||
+ r Int
|
||||
+ p Int
|
||||
+ salt String
|
||||
+}
|
||||
+
|
||||
+model Keystore {
|
||||
+ address String @id
|
||||
+ pubKey String
|
||||
+ encrypted String // stringified json
|
||||
+}
|
||||
+
|
||||
+model Config {
|
||||
+ id String @id @default(uuid())
|
||||
+ networkId Int
|
||||
+ chainId Int
|
||||
+ address String
|
||||
+ txoTreeDepth Int
|
||||
+ withdrawalTreeDepth Int
|
||||
+ nullifierTreeDepth Int
|
||||
+ challengePeriod Int
|
||||
+ minimumStake String
|
||||
+ referenceDepth Int
|
||||
+ maxUtxoPerTree String
|
||||
+ maxWithdrawalPerTree String
|
||||
+ utxoSubTreeDepth Int
|
||||
+ utxoSubTreeSize Int
|
||||
+ withdrawalSubTreeDepth Int
|
||||
+ withdrawalSubTreeSize Int
|
||||
+ chain ZkOPRUChain @relation(fields: [id], references: [id])
|
||||
+}
|
||||
+
|
||||
+model ZkOPRUChain {
|
||||
+ id String @id @default(uuid())
|
||||
+ config Config?
|
||||
+ nullifierTree NullifierTree
|
||||
+ // utxoTrees UtxoTree[]
|
||||
+ // withdrawalTrees WithdrawalTree[]
|
||||
+ blocks Block[]
|
||||
+}
|
||||
+
|
||||
+model Block {
|
||||
+ hash String @id
|
||||
+ header Header @relation(fields: [hash], references: [hash])
|
||||
+ status Int // NOT_FETCHED = 0 / FETCHED = 1 / PARTIALLY_VERIFEID = 2 / FULLY_VERIFIED = 3 / FINALIZED = 4 / INVALIDATED = 5 / REVERTED = 6
|
||||
+ proposalNum Int
|
||||
+ proposedAt Int
|
||||
+ proposalTx String // tx hash
|
||||
+ proposalData String // stringified json
|
||||
+ bootstrap Bootstrap @relation(fields: [hash], references: [hash])
|
||||
+ chainId String?
|
||||
+ chain ZkOPRUChain? @relation(fields: [chainId], references: [id])
|
||||
+}
|
||||
+
|
||||
+model Header {
|
||||
+ hash String @id
|
||||
+ txoTreeDepth Int
|
||||
+ withdrawalTreeDepth Int
|
||||
+ nullifierTreeDepth Int
|
||||
+ challengePeriod Int
|
||||
+ minimumStake String
|
||||
+ referenceDepth Int
|
||||
+ maxUtxoPerTree String
|
||||
+ maxWithdrawalPerTree String
|
||||
+ utxoSubTreeDepth Int
|
||||
+ utxoSubTreeSize Int
|
||||
+ withdrawalSubTreeDepth Int
|
||||
+ withdrawalSubTreeSize Int
|
||||
+}
|
||||
+
|
||||
+model Bootstrap {
|
||||
+ hash String @id
|
||||
+ utxoTreeIndex Int
|
||||
+ // utxoBootstrap String[]
|
||||
+ utxoBootstrap String // jsonified arr : sqlite does not support arr
|
||||
+ withdrawalTreeIndex Int
|
||||
+ // withdrawalBootstrap String[]
|
||||
+ withdrawalBootstrap String //jsonified arr : sqlite does not support arr
|
||||
+}
|
||||
+
|
||||
+model MassDeposit {
|
||||
+ index String @id
|
||||
+ merged String
|
||||
+ fee String
|
||||
+ blockNumber Int
|
||||
+ includedIn String?
|
||||
+ block Block? @relation(fields: [includedIn], references: [hash])
|
||||
+ deposits Deposit[]
|
||||
+}
|
||||
+
|
||||
+model Deposit {
|
||||
+ note String @id
|
||||
+ fee String
|
||||
+ transactionIndex Int
|
||||
+ logIndex Int
|
||||
+ blockNumber Int
|
||||
+ queuedAt String?
|
||||
+ includedIn String?
|
||||
+ massDeposit MassDeposit? @relation(fields: [queuedAt], references: [index])
|
||||
+}
|
||||
+
|
||||
+model Nullifier {
|
||||
+ index String @id
|
||||
+ nullified Boolean
|
||||
+ blockHash String
|
||||
+}
|
||||
+
|
||||
+model Note {
|
||||
+ hash String @id
|
||||
+ index String?
|
||||
+ eth String?
|
||||
+ pubKey String?
|
||||
+ salt String?
|
||||
+ tokenAddr String?
|
||||
+ erc20Amount String?
|
||||
+ nft String?
|
||||
+ type Int?
|
||||
+ withdrawOutTo String?
|
||||
+ fee String?
|
||||
+ status Int?
|
||||
+ treeId String?
|
||||
+ tree LightTree? @relation(fields: [treeId], references: [id])
|
||||
+}
|
||||
+
|
||||
+model TreeNode {
|
||||
+ treeId String
|
||||
+ nodeIndex String
|
||||
+ value String
|
||||
+ // tree UtxoTree @relation(fields: [treeId], references: [id])
|
||||
+ @@id([treeId, nodeIndex])
|
||||
+}
|
||||
+
|
||||
+model LightTree {
|
||||
+ id String @id @default(uuid())
|
||||
+ species Int // 0: utxo 1: withdrawal
|
||||
+ treeIndex Int
|
||||
+ zkopru String
|
||||
+ block String?
|
||||
+ // rollup sync data
|
||||
+ start String
|
||||
+ end String
|
||||
+ // rollup snapshot data
|
||||
+ root String
|
||||
+ index String
|
||||
+ siblings String // stringified str[]
|
||||
+ chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
+ @@index([species, treeIndex])
|
||||
+}
|
||||
+
|
||||
+model NullifierTree {
|
||||
+ id String @id @default(uuid())
|
||||
+ zkopru String
|
||||
+ treeIndex Int @unique
|
||||
+ block String?
|
||||
+ root String
|
||||
+ siblings String // stringified str[]
|
||||
+ chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
+}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource sqlite {
|
||||
provider = "sqlite"
|
||||
url = "***"
|
||||
}
|
||||
|
||||
// datasource posgres {
|
||||
// provider = "postgres"
|
||||
// url = "***"
|
||||
// }
|
||||
|
||||
model EncryptedWallet {
|
||||
id String @id @default(uuid())
|
||||
ciphertext String
|
||||
iv String
|
||||
algorithm String
|
||||
keylen Int
|
||||
kdf String
|
||||
N Int
|
||||
r Int
|
||||
p Int
|
||||
salt String
|
||||
}
|
||||
|
||||
model Keystore {
|
||||
address String @id
|
||||
pubKey String
|
||||
encrypted String // stringified json
|
||||
}
|
||||
|
||||
model Config {
|
||||
id String @id @default(uuid())
|
||||
networkId Int
|
||||
chainId Int
|
||||
address String
|
||||
txoTreeDepth Int
|
||||
withdrawalTreeDepth Int
|
||||
nullifierTreeDepth Int
|
||||
challengePeriod Int
|
||||
minimumStake String
|
||||
referenceDepth Int
|
||||
maxUtxoPerTree String
|
||||
maxWithdrawalPerTree String
|
||||
utxoSubTreeDepth Int
|
||||
utxoSubTreeSize Int
|
||||
withdrawalSubTreeDepth Int
|
||||
withdrawalSubTreeSize Int
|
||||
chain ZkOPRUChain @relation(fields: [id], references: [id])
|
||||
}
|
||||
|
||||
model ZkOPRUChain {
|
||||
id String @id @default(uuid())
|
||||
config Config?
|
||||
nullifierTree NullifierTree
|
||||
// utxoTrees UtxoTree[]
|
||||
// withdrawalTrees WithdrawalTree[]
|
||||
blocks Block[]
|
||||
}
|
||||
|
||||
model Block {
|
||||
hash String @id
|
||||
header Header @relation(fields: [hash], references: [hash])
|
||||
status Int // NOT_FETCHED = 0 / FETCHED = 1 / PARTIALLY_VERIFEID = 2 / FULLY_VERIFIED = 3 / FINALIZED = 4 / INVALIDATED = 5 / REVERTED = 6
|
||||
proposalNum Int
|
||||
proposedAt Int
|
||||
proposalTx String // tx hash
|
||||
proposalData String // stringified json
|
||||
bootstrap Bootstrap @relation(fields: [hash], references: [hash])
|
||||
chainId String?
|
||||
chain ZkOPRUChain? @relation(fields: [chainId], references: [id])
|
||||
}
|
||||
|
||||
model Header {
|
||||
hash String @id
|
||||
txoTreeDepth Int
|
||||
withdrawalTreeDepth Int
|
||||
nullifierTreeDepth Int
|
||||
challengePeriod Int
|
||||
minimumStake String
|
||||
referenceDepth Int
|
||||
maxUtxoPerTree String
|
||||
maxWithdrawalPerTree String
|
||||
utxoSubTreeDepth Int
|
||||
utxoSubTreeSize Int
|
||||
withdrawalSubTreeDepth Int
|
||||
withdrawalSubTreeSize Int
|
||||
}
|
||||
|
||||
model Bootstrap {
|
||||
hash String @id
|
||||
utxoTreeIndex Int
|
||||
// utxoBootstrap String[]
|
||||
utxoBootstrap String // jsonified arr : sqlite does not support arr
|
||||
withdrawalTreeIndex Int
|
||||
// withdrawalBootstrap String[]
|
||||
withdrawalBootstrap String //jsonified arr : sqlite does not support arr
|
||||
}
|
||||
|
||||
model MassDeposit {
|
||||
index String @id
|
||||
merged String
|
||||
fee String
|
||||
blockNumber Int
|
||||
includedIn String?
|
||||
block Block? @relation(fields: [includedIn], references: [hash])
|
||||
deposits Deposit[]
|
||||
}
|
||||
|
||||
model Deposit {
|
||||
note String @id
|
||||
fee String
|
||||
transactionIndex Int
|
||||
logIndex Int
|
||||
blockNumber Int
|
||||
queuedAt String?
|
||||
includedIn String?
|
||||
massDeposit MassDeposit? @relation(fields: [queuedAt], references: [index])
|
||||
}
|
||||
|
||||
model Nullifier {
|
||||
index String @id
|
||||
nullified Boolean
|
||||
blockHash String
|
||||
}
|
||||
|
||||
model Note {
|
||||
hash String @id
|
||||
index String?
|
||||
eth String?
|
||||
pubKey String?
|
||||
salt String?
|
||||
tokenAddr String?
|
||||
erc20Amount String?
|
||||
nft String?
|
||||
type Int?
|
||||
withdrawOutTo String?
|
||||
fee String?
|
||||
status Int?
|
||||
treeId String?
|
||||
tree LightTree? @relation(fields: [treeId], references: [id])
|
||||
}
|
||||
|
||||
model TreeNode {
|
||||
treeId String
|
||||
nodeIndex String
|
||||
value String
|
||||
// tree UtxoTree @relation(fields: [treeId], references: [id])
|
||||
@@id([treeId, nodeIndex])
|
||||
}
|
||||
|
||||
model LightTree {
|
||||
id String @id @default(uuid())
|
||||
species Int // 0: utxo 1: withdrawal
|
||||
treeIndex Int
|
||||
zkopru String
|
||||
block String?
|
||||
// rollup sync data
|
||||
start String
|
||||
end String
|
||||
// rollup snapshot data
|
||||
root String
|
||||
index String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
@@index([species, treeIndex])
|
||||
}
|
||||
|
||||
model NullifierTree {
|
||||
id String @id @default(uuid())
|
||||
zkopru String
|
||||
treeIndex Int @unique
|
||||
block String?
|
||||
root String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,136 +0,0 @@
|
||||
# Migration `20200605153155-change-header`
|
||||
|
||||
This migration has been generated by Wanseob Lim at 6/5/2020, 3:31:55 PM.
|
||||
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||
|
||||
## Database Steps
|
||||
|
||||
```sql
|
||||
PRAGMA foreign_keys=OFF;
|
||||
|
||||
CREATE TABLE "quaint"."EncryptedWallet" (
|
||||
"N" INTEGER NOT NULL ,"algorithm" TEXT NOT NULL ,"ciphertext" TEXT NOT NULL ,"id" TEXT NOT NULL ,"iv" TEXT NOT NULL ,"kdf" TEXT NOT NULL ,"keylen" INTEGER NOT NULL ,"p" INTEGER NOT NULL ,"r" INTEGER NOT NULL ,"salt" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"))
|
||||
|
||||
CREATE TABLE "quaint"."Keystore" (
|
||||
"address" TEXT NOT NULL ,"encrypted" TEXT NOT NULL ,"pubKey" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("address"))
|
||||
|
||||
CREATE TABLE "quaint"."Config" (
|
||||
"address" TEXT NOT NULL ,"chainId" INTEGER NOT NULL ,"challengePeriod" INTEGER NOT NULL ,"id" TEXT NOT NULL ,"maxUtxoPerTree" TEXT NOT NULL ,"maxWithdrawalPerTree" TEXT NOT NULL ,"minimumStake" TEXT NOT NULL ,"networkId" INTEGER NOT NULL ,"nullifierTreeDepth" INTEGER NOT NULL ,"referenceDepth" INTEGER NOT NULL ,"txoTreeDepth" INTEGER NOT NULL ,"utxoSubTreeDepth" INTEGER NOT NULL ,"utxoSubTreeSize" INTEGER NOT NULL ,"withdrawalSubTreeDepth" INTEGER NOT NULL ,"withdrawalSubTreeSize" INTEGER NOT NULL ,"withdrawalTreeDepth" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("id") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."ZkOPRUChain" (
|
||||
"id" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"))
|
||||
|
||||
CREATE TABLE "quaint"."Block" (
|
||||
"chainId" TEXT ,"hash" TEXT NOT NULL ,"proposalData" TEXT NOT NULL ,"proposalNum" INTEGER NOT NULL ,"proposalTx" TEXT NOT NULL ,"proposedAt" INTEGER NOT NULL ,"status" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("hash"),FOREIGN KEY ("hash") REFERENCES "Header"("hash") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY ("hash") REFERENCES "Bootstrap"("hash") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY ("chainId") REFERENCES "ZkOPRUChain"("id") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Header" (
|
||||
"depositRoot" TEXT NOT NULL ,"fee" TEXT NOT NULL ,"hash" TEXT NOT NULL ,"metadata" TEXT NOT NULL ,"migrationRoot" TEXT NOT NULL ,"nullifierRoot" TEXT NOT NULL ,"parentBlock" TEXT NOT NULL ,"proposer" TEXT NOT NULL ,"txRoot" TEXT NOT NULL ,"utxoIndex" TEXT NOT NULL ,"utxoRoot" TEXT NOT NULL ,"withdrawalIndex" TEXT NOT NULL ,"withdrawalRoot" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("hash"))
|
||||
|
||||
CREATE TABLE "quaint"."Bootstrap" (
|
||||
"hash" TEXT NOT NULL ,"utxoBootstrap" TEXT NOT NULL ,"utxoTreeIndex" INTEGER NOT NULL ,"withdrawalBootstrap" TEXT NOT NULL ,"withdrawalTreeIndex" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("hash"))
|
||||
|
||||
CREATE TABLE "quaint"."MassDeposit" (
|
||||
"blockNumber" INTEGER NOT NULL ,"fee" TEXT NOT NULL ,"includedIn" TEXT ,"index" TEXT NOT NULL ,"merged" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("index"),FOREIGN KEY ("includedIn") REFERENCES "Block"("hash") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Deposit" (
|
||||
"blockNumber" INTEGER NOT NULL ,"fee" TEXT NOT NULL ,"includedIn" TEXT ,"logIndex" INTEGER NOT NULL ,"note" TEXT NOT NULL ,"queuedAt" TEXT ,"transactionIndex" INTEGER NOT NULL ,
|
||||
PRIMARY KEY ("note"),FOREIGN KEY ("queuedAt") REFERENCES "MassDeposit"("index") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."Nullifier" (
|
||||
"blockHash" TEXT NOT NULL ,"index" TEXT NOT NULL ,"nullified" BOOLEAN NOT NULL ,
|
||||
PRIMARY KEY ("index"))
|
||||
|
||||
CREATE TABLE "quaint"."Note" (
|
||||
"erc20Amount" TEXT ,"eth" TEXT ,"fee" TEXT ,"hash" TEXT NOT NULL ,"index" TEXT ,"nft" TEXT ,"pubKey" TEXT ,"salt" TEXT ,"status" INTEGER ,"tokenAddr" TEXT ,"treeId" TEXT ,"type" INTEGER ,"withdrawOutTo" TEXT ,
|
||||
PRIMARY KEY ("hash"),FOREIGN KEY ("treeId") REFERENCES "LightTree"("id") ON DELETE SET NULL ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."TreeNode" (
|
||||
"nodeIndex" TEXT NOT NULL ,"treeId" TEXT NOT NULL ,"value" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("treeId","nodeIndex"))
|
||||
|
||||
CREATE TABLE "quaint"."LightTree" (
|
||||
"block" TEXT ,"end" TEXT NOT NULL ,"id" TEXT NOT NULL ,"index" TEXT NOT NULL ,"root" TEXT NOT NULL ,"siblings" TEXT NOT NULL ,"species" INTEGER NOT NULL ,"start" TEXT NOT NULL ,"treeIndex" INTEGER NOT NULL ,"zkopru" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("zkopru") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE TABLE "quaint"."NullifierTree" (
|
||||
"block" TEXT ,"id" TEXT NOT NULL ,"root" TEXT NOT NULL ,"siblings" TEXT NOT NULL ,"treeIndex" INTEGER NOT NULL ,"zkopru" TEXT NOT NULL ,
|
||||
PRIMARY KEY ("id"),FOREIGN KEY ("zkopru") REFERENCES "ZkOPRUChain"("id") ON DELETE CASCADE ON UPDATE CASCADE)
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."Config_id" ON "Config"("id")
|
||||
|
||||
CREATE INDEX "quaint"."LightTree.species_treeIndex" ON "LightTree"("species","treeIndex")
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."NullifierTree.treeIndex" ON "NullifierTree"("treeIndex")
|
||||
|
||||
CREATE UNIQUE INDEX "quaint"."NullifierTree_zkopru" ON "NullifierTree"("zkopru")
|
||||
|
||||
PRAGMA "quaint".foreign_key_check;
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
```
|
||||
|
||||
## Changes
|
||||
|
||||
```diff
|
||||
diff --git schema.prisma schema.prisma
|
||||
migration 20200605150020-initial..20200605153155-change-header
|
||||
--- datamodel.dml
|
||||
+++ datamodel.dml
|
||||
@@ -3,14 +3,14 @@
|
||||
}
|
||||
datasource sqlite {
|
||||
provider = "sqlite"
|
||||
- url = "***"
|
||||
+ url = env("DATABASE_URL")
|
||||
}
|
||||
// datasource posgres {
|
||||
// provider = "postgres"
|
||||
-// url = "***"
|
||||
+// url = env("POSTGRES_URL")
|
||||
// }
|
||||
model EncryptedWallet {
|
||||
id String @id @default(uuid())
|
||||
@@ -74,20 +74,20 @@
|
||||
}
|
||||
model Header {
|
||||
hash String @id
|
||||
- txoTreeDepth Int
|
||||
- withdrawalTreeDepth Int
|
||||
- nullifierTreeDepth Int
|
||||
- challengePeriod Int
|
||||
- minimumStake String
|
||||
- referenceDepth Int
|
||||
- maxUtxoPerTree String
|
||||
- maxWithdrawalPerTree String
|
||||
- utxoSubTreeDepth Int
|
||||
- utxoSubTreeSize Int
|
||||
- withdrawalSubTreeDepth Int
|
||||
- withdrawalSubTreeSize Int
|
||||
+ proposer String
|
||||
+ parentBlock String
|
||||
+ metadata String
|
||||
+ fee String
|
||||
+ utxoRoot String
|
||||
+ utxoIndex String
|
||||
+ nullifierRoot String
|
||||
+ withdrawalRoot String
|
||||
+ withdrawalIndex String
|
||||
+ txRoot String
|
||||
+ depositRoot String
|
||||
+ migrationRoot String
|
||||
}
|
||||
model Bootstrap {
|
||||
hash String @id
|
||||
```
|
||||
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource sqlite {
|
||||
provider = "sqlite"
|
||||
url = "***"
|
||||
}
|
||||
|
||||
// datasource posgres {
|
||||
// provider = "postgres"
|
||||
// url = "***"
|
||||
// }
|
||||
|
||||
model EncryptedWallet {
|
||||
id String @id @default(uuid())
|
||||
ciphertext String
|
||||
iv String
|
||||
algorithm String
|
||||
keylen Int
|
||||
kdf String
|
||||
N Int
|
||||
r Int
|
||||
p Int
|
||||
salt String
|
||||
}
|
||||
|
||||
model Keystore {
|
||||
address String @id
|
||||
pubKey String
|
||||
encrypted String // stringified json
|
||||
}
|
||||
|
||||
model Config {
|
||||
id String @id @default(uuid())
|
||||
networkId Int
|
||||
chainId Int
|
||||
address String
|
||||
txoTreeDepth Int
|
||||
withdrawalTreeDepth Int
|
||||
nullifierTreeDepth Int
|
||||
challengePeriod Int
|
||||
minimumStake String
|
||||
referenceDepth Int
|
||||
maxUtxoPerTree String
|
||||
maxWithdrawalPerTree String
|
||||
utxoSubTreeDepth Int
|
||||
utxoSubTreeSize Int
|
||||
withdrawalSubTreeDepth Int
|
||||
withdrawalSubTreeSize Int
|
||||
chain ZkOPRUChain @relation(fields: [id], references: [id])
|
||||
}
|
||||
|
||||
model ZkOPRUChain {
|
||||
id String @id @default(uuid())
|
||||
config Config?
|
||||
nullifierTree NullifierTree
|
||||
// utxoTrees UtxoTree[]
|
||||
// withdrawalTrees WithdrawalTree[]
|
||||
blocks Block[]
|
||||
}
|
||||
|
||||
model Block {
|
||||
hash String @id
|
||||
header Header @relation(fields: [hash], references: [hash])
|
||||
status Int // NOT_FETCHED = 0 / FETCHED = 1 / PARTIALLY_VERIFEID = 2 / FULLY_VERIFIED = 3 / FINALIZED = 4 / INVALIDATED = 5 / REVERTED = 6
|
||||
proposalNum Int
|
||||
proposedAt Int
|
||||
proposalTx String // tx hash
|
||||
proposalData String // stringified json
|
||||
bootstrap Bootstrap @relation(fields: [hash], references: [hash])
|
||||
chainId String?
|
||||
chain ZkOPRUChain? @relation(fields: [chainId], references: [id])
|
||||
}
|
||||
|
||||
model Header {
|
||||
hash String @id
|
||||
proposer String
|
||||
parentBlock String
|
||||
metadata String
|
||||
fee String
|
||||
utxoRoot String
|
||||
utxoIndex String
|
||||
nullifierRoot String
|
||||
withdrawalRoot String
|
||||
withdrawalIndex String
|
||||
txRoot String
|
||||
depositRoot String
|
||||
migrationRoot String
|
||||
}
|
||||
|
||||
model Bootstrap {
|
||||
hash String @id
|
||||
utxoTreeIndex Int
|
||||
// utxoBootstrap String[]
|
||||
utxoBootstrap String // jsonified arr : sqlite does not support arr
|
||||
withdrawalTreeIndex Int
|
||||
// withdrawalBootstrap String[]
|
||||
withdrawalBootstrap String //jsonified arr : sqlite does not support arr
|
||||
}
|
||||
|
||||
model MassDeposit {
|
||||
index String @id
|
||||
merged String
|
||||
fee String
|
||||
blockNumber Int
|
||||
includedIn String?
|
||||
block Block? @relation(fields: [includedIn], references: [hash])
|
||||
deposits Deposit[]
|
||||
}
|
||||
|
||||
model Deposit {
|
||||
note String @id
|
||||
fee String
|
||||
transactionIndex Int
|
||||
logIndex Int
|
||||
blockNumber Int
|
||||
queuedAt String?
|
||||
includedIn String?
|
||||
massDeposit MassDeposit? @relation(fields: [queuedAt], references: [index])
|
||||
}
|
||||
|
||||
model Nullifier {
|
||||
index String @id
|
||||
nullified Boolean
|
||||
blockHash String
|
||||
}
|
||||
|
||||
model Note {
|
||||
hash String @id
|
||||
index String?
|
||||
eth String?
|
||||
pubKey String?
|
||||
salt String?
|
||||
tokenAddr String?
|
||||
erc20Amount String?
|
||||
nft String?
|
||||
type Int?
|
||||
withdrawOutTo String?
|
||||
fee String?
|
||||
status Int?
|
||||
treeId String?
|
||||
tree LightTree? @relation(fields: [treeId], references: [id])
|
||||
}
|
||||
|
||||
model TreeNode {
|
||||
treeId String
|
||||
nodeIndex String
|
||||
value String
|
||||
// tree UtxoTree @relation(fields: [treeId], references: [id])
|
||||
@@id([treeId, nodeIndex])
|
||||
}
|
||||
|
||||
model LightTree {
|
||||
id String @id @default(uuid())
|
||||
species Int // 0: utxo 1: withdrawal
|
||||
treeIndex Int
|
||||
zkopru String
|
||||
block String?
|
||||
// rollup sync data
|
||||
start String
|
||||
end String
|
||||
// rollup snapshot data
|
||||
root String
|
||||
index String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
@@index([species, treeIndex])
|
||||
}
|
||||
|
||||
model NullifierTree {
|
||||
id String @id @default(uuid())
|
||||
zkopru String
|
||||
treeIndex Int @unique
|
||||
block String?
|
||||
root String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
{
|
||||
"version": "0.3.14-fixed",
|
||||
"steps": [
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "proposer",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "parentBlock",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "metadata",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "fee",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "utxoRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "utxoIndex",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "nullifierRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "withdrawalRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "withdrawalIndex",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "txRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "depositRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "Header",
|
||||
"field": "migrationRoot",
|
||||
"type": "String",
|
||||
"arity": "Required"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "txoTreeDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "withdrawalTreeDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "nullifierTreeDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "challengePeriod"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "minimumStake"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "referenceDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "maxUtxoPerTree"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "maxWithdrawalPerTree"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "utxoSubTreeDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "utxoSubTreeSize"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "withdrawalSubTreeDepth"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "Header",
|
||||
"field": "withdrawalSubTreeSize"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
# Prisma Migrate lockfile v1
|
||||
|
||||
20200605150020-initial
|
||||
20200605153155-change-header
|
||||
@@ -32,11 +32,11 @@ model Keystore {
|
||||
}
|
||||
|
||||
model Config {
|
||||
id String @id @default(uuid())
|
||||
id String @unique
|
||||
networkId Int
|
||||
chainId Int
|
||||
address String
|
||||
txoTreeDepth Int
|
||||
utxoTreeDepth Int
|
||||
withdrawalTreeDepth Int
|
||||
nullifierTreeDepth Int
|
||||
challengePeriod Int
|
||||
@@ -48,29 +48,27 @@ model Config {
|
||||
utxoSubTreeSize Int
|
||||
withdrawalSubTreeDepth Int
|
||||
withdrawalSubTreeSize Int
|
||||
chain ZkOPRUChain @relation(fields: [id], references: [id])
|
||||
@@id([networkId, chainId, address])
|
||||
}
|
||||
|
||||
model ZkOPRUChain {
|
||||
id String @id @default(uuid())
|
||||
config Config?
|
||||
nullifierTree NullifierTree
|
||||
// utxoTrees UtxoTree[]
|
||||
// withdrawalTrees WithdrawalTree[]
|
||||
blocks Block[]
|
||||
model Proposal {
|
||||
hash String @id
|
||||
proposalNum Int
|
||||
proposedAt Int
|
||||
proposalTx String // tx hash
|
||||
proposalData String? // stringified json
|
||||
fetched String?
|
||||
finalized Boolean?
|
||||
invalidated Boolean?
|
||||
block Block? @relation(fields: [fetched], references: [hash])
|
||||
}
|
||||
|
||||
model Block {
|
||||
hash String @id
|
||||
verified Boolean?
|
||||
header Header @relation(fields: [hash], references: [hash])
|
||||
status Int // NOT_FETCHED = 0 / FETCHED = 1 / PARTIALLY_VERIFEID = 2 / FULLY_VERIFIED = 3 / FINALIZED = 4 / INVALIDATED = 5 / REVERTED = 6
|
||||
proposalNum Int
|
||||
proposedAt Int
|
||||
proposalTx String // tx hash
|
||||
proposalData String // stringified json
|
||||
bootstrap Bootstrap @relation(fields: [hash], references: [hash])
|
||||
chainId String?
|
||||
chain ZkOPRUChain? @relation(fields: [chainId], references: [id])
|
||||
proposal Proposal
|
||||
bootstrap Bootstrap?
|
||||
}
|
||||
|
||||
model Header {
|
||||
@@ -90,13 +88,15 @@ model Header {
|
||||
}
|
||||
|
||||
model Bootstrap {
|
||||
hash String @id
|
||||
id String @id @default(uuid())
|
||||
blockHash String? @unique
|
||||
utxoTreeIndex Int
|
||||
// utxoBootstrap String[]
|
||||
utxoBootstrap String // jsonified arr : sqlite does not support arr
|
||||
withdrawalTreeIndex Int
|
||||
// withdrawalBootstrap String[]
|
||||
withdrawalBootstrap String //jsonified arr : sqlite does not support arr
|
||||
block Block? @relation(fields: [blockHash], references: [hash])
|
||||
}
|
||||
|
||||
model MassDeposit {
|
||||
@@ -105,8 +105,6 @@ model MassDeposit {
|
||||
fee String
|
||||
blockNumber Int
|
||||
includedIn String?
|
||||
block Block? @relation(fields: [includedIn], references: [hash])
|
||||
deposits Deposit[]
|
||||
}
|
||||
|
||||
model Deposit {
|
||||
@@ -115,15 +113,12 @@ model Deposit {
|
||||
transactionIndex Int
|
||||
logIndex Int
|
||||
blockNumber Int
|
||||
queuedAt String?
|
||||
includedIn String?
|
||||
massDeposit MassDeposit? @relation(fields: [queuedAt], references: [index])
|
||||
queuedAt String
|
||||
}
|
||||
|
||||
model Nullifier {
|
||||
index String @id
|
||||
nullified Boolean
|
||||
blockHash String
|
||||
}
|
||||
|
||||
model Note {
|
||||
@@ -139,8 +134,9 @@ model Note {
|
||||
withdrawOutTo String?
|
||||
fee String?
|
||||
status Int?
|
||||
treeId String?
|
||||
tree LightTree? @relation(fields: [treeId], references: [id])
|
||||
noteType Int?
|
||||
treeIndex Int?
|
||||
tree LightTree? @relation(fields: [noteType, treeIndex], references: [species, treeIndex])
|
||||
}
|
||||
|
||||
model TreeNode {
|
||||
@@ -152,10 +148,9 @@ model TreeNode {
|
||||
}
|
||||
|
||||
model LightTree {
|
||||
id String @id @default(uuid())
|
||||
id String @default(uuid()) @unique
|
||||
species Int // 0: utxo 1: withdrawal
|
||||
treeIndex Int
|
||||
zkopru String
|
||||
block String?
|
||||
// rollup sync data
|
||||
start String
|
||||
@@ -164,16 +159,13 @@ model LightTree {
|
||||
root String
|
||||
index String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
@@index([species, treeIndex])
|
||||
@@id([species, treeIndex])
|
||||
}
|
||||
|
||||
model NullifierTree {
|
||||
id String @id @default(uuid())
|
||||
zkopru String
|
||||
treeIndex Int @unique
|
||||
block String?
|
||||
root String
|
||||
siblings String // stringified str[]
|
||||
chain ZkOPRUChain @relation(fields: [zkopru], references: [id])
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -20,6 +20,8 @@ export enum BlockStatus {
|
||||
REVERTED = 6,
|
||||
}
|
||||
|
||||
export const NULLIFIER_TREE_ID = 'nullifier-tree'
|
||||
|
||||
export {
|
||||
LightTree,
|
||||
TreeNode,
|
||||
@@ -28,8 +30,18 @@ export {
|
||||
EncryptedWallet,
|
||||
Block,
|
||||
Header,
|
||||
Bootstrap,
|
||||
Config,
|
||||
Deposit,
|
||||
MassDeposit,
|
||||
Proposal,
|
||||
} from '@prisma/client'
|
||||
|
||||
export interface MockupDB {
|
||||
db: DB
|
||||
terminate: () => Promise<void>
|
||||
}
|
||||
|
||||
export class DB {
|
||||
constructor(option?: PrismaClientOptions) {
|
||||
this.prisma = new PrismaClient(option)
|
||||
@@ -62,27 +74,24 @@ export class DB {
|
||||
},
|
||||
}
|
||||
|
||||
static async mockup(): Promise<{
|
||||
instance: DB
|
||||
terminate: () => Promise<void>
|
||||
}> {
|
||||
static async mockup(): Promise<MockupDB> {
|
||||
const dbName = `${v4()}.db`
|
||||
const dbPath = `${path.join(path.resolve('.'), dbName)}`
|
||||
const predefined = `${path.join(
|
||||
path.resolve(__dirname),
|
||||
'../prisma/schema.db',
|
||||
'../prisma/dev.db',
|
||||
)}`
|
||||
console.log('predefiend, ', predefined)
|
||||
fs.promises.copyFile(predefined, dbPath)
|
||||
const instance = new DB({
|
||||
const db = new DB({
|
||||
datasources: {
|
||||
sqlite: `file://${dbPath}`,
|
||||
},
|
||||
})
|
||||
const terminate = async () => {
|
||||
fs.unlinkSync(dbPath)
|
||||
await instance.prisma.disconnect()
|
||||
await db.prisma.disconnect()
|
||||
}
|
||||
return { instance, terminate }
|
||||
return { db, terminate }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"~core/*": ["core/src/*"],
|
||||
"~database/*": ["database/src/*"],
|
||||
"~dataset/*": ["dataset/src/*"],
|
||||
"~prisma/*": ["prisma/src/*"],
|
||||
"~transaction/*": ["transaction/src/*"],
|
||||
"~tree/*": ["tree/src/*"],
|
||||
"~utils/*": ["utils/src/*"],
|
||||
|
||||
Reference in New Issue
Block a user