Skip to content

Commit

Permalink
fix: πŸ› Optimize Proof Submission
Browse files Browse the repository at this point in the history
βœ… Closes: #19
  • Loading branch information
lovel8 committed Mar 26, 2024
1 parent 039251a commit c81586c
Show file tree
Hide file tree
Showing 16 changed files with 904 additions and 699 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ shed-linux
shed-macos
shed-win.exe
.env
yarn.lock
*.lock
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"type": "node",
"request": "launch",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceFolder}/src/index.ts", "getEscrowRequirement", "--datasetId", "1", "--type", "5"],
"args": ["${workspaceFolder}/src/index.ts", "updateDatasetTimeoutParameters", "-i", "5", "-p", "200000", "-a", "200000"],
//"args": ["${workspaceFolder}/src/index.ts", "deposit", "-i", "5", "-m", "0", "-o", "0x09C6DEE9DB5e7dF2b18283c0CFCf714fEDB692d7", "-a", "10000000000"],
"cwd": "${workspaceFolder}",
"sourceMaps": true
}
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"homepage": "https://github.com/dataswap/shed#readme",
"devDependencies": {
"@dataswapjs/dataswapjs": "^0.25.0",
"@dataswapjs/dataswapjs": "^0.25.1",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.26",
"@types/yargs": "^17.0.32",
Expand Down
99 changes: 78 additions & 21 deletions src/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
********************************************************************************/

import yargs from "yargs"
import {
submitDatasetMetadata,
updateDatasetTimeoutParameters,
submitDatasetReplicaRequirements,
} from "./dataset/metadata/repo"
import {
submitDatasetProof,
submitDatasetChallengeProofs,
} from "./dataset/proof/repo"
import { getEscrowRequirement, deposit } from "./finance/repo"
import { DatasetMetadatas } from "./dataset/metadata/repo"
import { DatasetProofs } from "./dataset/proof/repo"
import { Finance } from "./finance/repo"

import { Context } from "./shared/context"

Expand Down Expand Up @@ -112,6 +105,30 @@ const argv = yargs
type: "number",
},
})
.command("completeEscrow", "completeEscrow", {
datasetId: {
description: "Dataset Id",
alias: "i",
demandOption: true,
type: "number",
},
})
.command("submitDatasetProofCompleted", "Submit dataset proof completed", {
datasetId: {
description: "Dataset Id",
alias: "i",
demandOption: true,
type: "number",
},
})
.command("auditorStake", "auditor stake amount", {
datasetId: {
description: "Dataset Id",
alias: "i",
demandOption: true,
type: "number",
},
})
.command(
"submitDatasetChallengeProofs",
"Submit dataset challenge proofs",
Expand Down Expand Up @@ -162,17 +179,32 @@ const argv = yargs
type: "string",
},
})
.command("getDatasetState", "Get dataset state", {
datasetId: {
description:
"dataset state: None = 0,MetadataSubmitted=1,RequirementSubmitted=2,WaitEscrow=3,ProofSubmitted=4,Approved=5,Rejected=6",
alias: "i",
demandOption: true,
type: "number",
},
})
.command("getEscrowRequirement", "Get escrow requirement", {
datasetId: {
description: "Dataset Id",
alias: "i",
type: "number",
},
size: {
description: "Data size",
description:
"Data size, when DatacapCollateralRequirment and DatacapChunkLandRequirment",
alias: "s",
type: "number",
},
replicasCount: {
description: "Replicas count, when DatacapCollateralRequirment",
alias: "r",
type: "number",
},
type: {
description:
"escrow type:(DatacapCollateralRequirment=0; DatacapChunkLandRequirment=1; ChallengeCommissionRequirment=2; ChallengeAuditCollateralRequirment=3; ProofAuditCollateralRequirment=4; DisputeAuditCollateralRequirment=5)",
Expand All @@ -192,29 +224,29 @@ const argv = yargs
export async function run(context: Context) {
switch (argv._[0]) {
case "submitDatasetMetadata":
await submitDatasetMetadata({
await new DatasetMetadatas().submitDatasetMetadata({
context,
path: String(argv.path),
})
break
case "updateDatasetTimeoutParameters":
console.log(
await updateDatasetTimeoutParameters({
await new DatasetMetadatas().updateDatasetTimeoutParameters({
context,
datasetId: Number(argv.datasetId),
proofBlockCount: argv.proofBlockCount as bigint,
auditBlockCount: argv.auditBlockCount as bigint,
proofBlockCount: BigInt(String(argv.proofBlockCount)),
auditBlockCount: BigInt(String(argv.auditBlockCount)),
})
)
break
case "submitDatasetReplicaRequirements":
await submitDatasetReplicaRequirements({
await new DatasetMetadatas().submitDatasetReplicaRequirements({
context,
path: String(argv.path),
})
break
case "submitDatasetProof":
await submitDatasetProof({
await new DatasetProofs().submitDatasetProof({
context,
datasetId: Number(argv.datasetId),
dataType: Number(argv.dataType),
Expand All @@ -223,31 +255,56 @@ export async function run(context: Context) {
chunk: Number(argv.chunk),
})
break
case "completeEscrow":
await new DatasetProofs().completeEscrow({
context,
datasetId: Number(argv.datasetId),
})
break
case "submitDatasetProofCompleted":
await new DatasetProofs().submitDatasetProofCompleted({
context,
datasetId: Number(argv.datasetId),
})
break
case "auditorStake":
await new DatasetProofs().auditorStake({
context,
datasetId: Number(argv.datasetId),
})
break
case "submitDatasetChallengeProofs":
await submitDatasetChallengeProofs({
await new DatasetProofs().submitDatasetChallengeProofs({
context,
datasetId: Number(argv.datasetId),
path: String(argv.path),
})
break
case "deposit":
await deposit({
await new Finance().deposit({
context,
datasetId: Number(argv.datasetId),
matchingId: Number(argv.matchingId),
owner: String(argv.owner),
token: String(argv.token),
amount: argv.amount as bigint,
amount: BigInt(String(argv.amount)),
})
break
case "getDatasetState":
await new DatasetMetadatas().getDatasetState({
context,
datasetId: Number(argv.datasetId),
})
break
case "getEscrowRequirement":
console.log(
"amount: ",
await getEscrowRequirement({
await new Finance().getEscrowRequirement({
context,
datasetId: Number(argv.datasetId),
size: Number(argv.size),
type: Number(argv.type),
replicasCount: Number(argv.replicasCount),
})
)
break
Expand Down
Loading

0 comments on commit c81586c

Please sign in to comment.