Skip to content

Commit 597f367

Browse files
magik6ksnadrus
authored andcommitted
Curio Snark Marketplace (#484)
* move proofsvc here * layout tasks * request task * missing sql schema * implement prove * proofshare: Submit task * proofshare webrpc * proofshare web * make gen * fixes for basic flow * client schema/ui * improve market ui more * pure Go post proof verification * proof bincode encode * bg task name * wip genadt * cborlink * update cbor-gen * init router * debug commands * working deposit * most flows working * Withdraw, DST * Complete Withdraw * more info * Plumb most of the remaining stuff * router wallet ui start * webui balance add * make gen * client message listing * usable withdrawal * ui: price settings * pricing integration * sort of working c1outraw cbor * undo * wip pricing changes * voucher check utils * persist provider payments * wip * wip remote task pipeline * cleanup client * guided setup for non-sp cluster * correct enable * make gen * wallet source fixes * don't retry bad batch tasks for no reason * missing clientctl * closer to working * payment recovery * fix payment undo * ocean of fixes * make gen * basic backoffs * record provider payments correctly * some settle ui * redeem improvements * ui: wallet hover details * provider settle button * minor fixes * more submit retry * snap vanilla verif on proof type * missing files * snap snark check * remote snap prove task * snap pricing * close to final provider ui * gen, new ledger types * more types * block helpers * svc l2 iteration * make gen * svc contract final touches * snksvc client cli * snk ask withdraw * dedup reassigned requests * handle pow * prove oldest first * sig msg type, gen * signing impl * basic noncecache * signer fixes * wire up signatures * make gen * tos * tos in schema * deployment settings * Apply suggestions from code review Co-authored-by: Andrew Jackson (Ajax) <[email protected]> * tos finalization * add licence term to psvc packages * make gen * rm temp task skip * fix initial provider form * remove useless price epoch from proof request * gone work handling * cache client read calls * fixed client price math * log zero price * pricing debug * more pricinc debug * fix price cache * caches are hard * allow separate cql db * register proving tasks when remote proving is enabled * what * more detailed logs * filter market prices * good logs are good * Provider autosettle * fix infer nvme devices * Don't auto-accept AI suggestions * Wallet Balance Manager * gofmt * make gen * web: compact pretty epoch in porep pipeline * del unused scripts/gen.go * lint fixes * faster poll * poll metrics * client payments table stats * provider: smarter sched logic * hold the correct way * attempt at smart storage allocation * storage tuning * rm bs fetch limit * fix likely deadlock * refactor client pipeline * gen, default upload max * review * fix orphan send * fix name len limit * fix null in psvc poll * eww * fix porep get * fix snap too * fix poll edge-cases * send fixes * filter spdis in createpayment correctly * fix bad src address * fix proof retry hopefully * optimized snark candidate picker * mark finished submit when orphaned * make gen * cleanup abandoned tasks * more generous retry * fix lint * drop default hardhat readme * validate wallet input strings * fix ctxlk test * fix chainhead ddos * address review * make gen * translations * gen translations * cleanup stray todo --------- Co-authored-by: Andrew Jackson (Ajax) <[email protected]>
1 parent 638fb41 commit 597f367

File tree

113 files changed

+27201
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+27201
-548
lines changed

cmd/curio/calc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The config can be used directly with SupraSeal binaries to test it without invol
162162
},
163163
},
164164
Action: func(cctx *cli.Context) error {
165-
cstr, err := sealsupra.GenerateSupraSealConfigString(cctx.Bool("dual-hashers"), cctx.Int("batch-size"), nil)
165+
cstr, _, err := sealsupra.GenerateSupraSealConfigString(cctx.Bool("dual-hashers"), cctx.Int("batch-size"), nil)
166166
if err != nil {
167167
return err
168168
}

cmd/curio/debug-proofsvc.go

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"encoding/hex"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/ipfs/go-cid"
12+
"github.com/urfave/cli/v2"
13+
"golang.org/x/xerrors"
14+
15+
"github.com/filecoin-project/go-address"
16+
"github.com/filecoin-project/go-state-types/abi"
17+
18+
curioproof "github.com/filecoin-project/curio/lib/proof"
19+
"github.com/filecoin-project/curio/lib/proofsvc"
20+
"github.com/filecoin-project/curio/lib/proofsvc/common"
21+
22+
"github.com/filecoin-project/lotus/chain/types"
23+
cliutil "github.com/filecoin-project/lotus/cli/util"
24+
)
25+
26+
type commit2In struct {
27+
SectorNum int64 `json:"SectorNum"`
28+
Phase1Out []byte `json:"Phase1Out"`
29+
SectorSize uint64 `json:"SectorSize"`
30+
}
31+
32+
var proofsvcClientCmd = &cli.Command{
33+
Name: "proofsvc-client",
34+
Usage: "Interact with the remote proof service",
35+
Subcommands: []*cli.Command{
36+
proofsvcCreateVoucherCmd,
37+
proofsvcSubmitCmd,
38+
proofsvcStatusCmd,
39+
},
40+
}
41+
42+
var proofsvcCreateVoucherCmd = &cli.Command{
43+
Name: "create-voucher",
44+
Usage: "Create a client voucher",
45+
Flags: []cli.Flag{
46+
&cli.StringFlag{Name: "client", Required: true},
47+
&cli.StringFlag{Name: "amount", Required: true},
48+
},
49+
Action: func(cctx *cli.Context) error {
50+
clientStr := cctx.String("client")
51+
amountStr := cctx.String("amount")
52+
53+
full, closer, err := cliutil.GetFullNodeAPIV1(cctx)
54+
if err != nil {
55+
return err
56+
}
57+
defer closer()
58+
59+
svc := common.NewService(full)
60+
61+
clientAddr, err := address.NewFromString(clientStr)
62+
if err != nil {
63+
return err
64+
}
65+
66+
cumulativeAmount, err := types.ParseFIL(amountStr)
67+
if err != nil {
68+
return err
69+
}
70+
71+
idAddr, err := full.StateLookupID(cctx.Context, clientAddr, types.EmptyTSK)
72+
if err != nil {
73+
return err
74+
}
75+
clientID, err := address.IDFromAddress(idAddr)
76+
if err != nil {
77+
return err
78+
}
79+
80+
state, err := svc.GetClientState(cctx.Context, clientID)
81+
if err != nil {
82+
return err
83+
}
84+
nonce := state.LastNonce + 1
85+
cumulativeAmount = types.FIL(types.BigAdd(types.BigInt(state.VoucherRedeemed), types.BigInt(cumulativeAmount)))
86+
87+
voucher, err := svc.CreateClientVoucher(cctx.Context, clientID, cumulativeAmount.Int, nonce)
88+
if err != nil {
89+
return err
90+
}
91+
92+
sig, err := full.WalletSign(cctx.Context, clientAddr, voucher)
93+
if err != nil {
94+
return err
95+
}
96+
97+
output := struct {
98+
Voucher string `json:"voucher"`
99+
Signature string `json:"signature"`
100+
Nonce uint64 `json:"nonce"`
101+
}{
102+
Voucher: hex.EncodeToString(voucher),
103+
Signature: hex.EncodeToString(sig.Data),
104+
Nonce: nonce,
105+
}
106+
107+
enc, err := json.MarshalIndent(output, "", " ")
108+
if err != nil {
109+
return err
110+
}
111+
fmt.Print(string(enc))
112+
return nil
113+
},
114+
}
115+
116+
var proofsvcSubmitCmd = &cli.Command{
117+
Name: "submit",
118+
Usage: "Submit a proof request",
119+
Flags: []cli.Flag{
120+
&cli.StringFlag{Name: "c1", Usage: "path to lotus-bench c1 json", Required: true},
121+
&cli.StringFlag{Name: "miner", Usage: "miner address", Required: true},
122+
&cli.Uint64Flag{Name: "client-id", Required: true},
123+
&cli.Uint64Flag{Name: "nonce", Required: true},
124+
&cli.StringFlag{Name: "amount", Required: true},
125+
&cli.StringFlag{Name: "sig", Required: true},
126+
},
127+
Action: func(cctx *cli.Context) error {
128+
inb, err := os.ReadFile(cctx.String("c1"))
129+
if err != nil {
130+
return err
131+
}
132+
var c2 commit2In
133+
if err := json.Unmarshal(inb, &c2); err != nil {
134+
return err
135+
}
136+
137+
minerAddr, err := address.NewFromString(cctx.String("miner"))
138+
if err != nil {
139+
return err
140+
}
141+
idAddr, err := address.IDFromAddress(minerAddr)
142+
if err != nil {
143+
return err
144+
}
145+
146+
c1raw, err := curioproof.DecodeCommit1OutRaw(bytes.NewReader(c2.Phase1Out))
147+
if err != nil {
148+
return xerrors.Errorf("decode c1: %w", err)
149+
}
150+
151+
pd := common.ProofData{
152+
SectorID: &abi.SectorID{Miner: abi.ActorID(idAddr), Number: abi.SectorNumber(c2.SectorNum)},
153+
PoRep: &c1raw,
154+
}
155+
156+
pbytes, err := json.Marshal(pd)
157+
if err != nil {
158+
return err
159+
}
160+
161+
ctx := context.Background()
162+
cid, err := proofsvc.UploadProofData(ctx, pbytes)
163+
if err != nil {
164+
return err
165+
}
166+
167+
amt, err := types.ParseFIL(cctx.String("amount"))
168+
if err != nil {
169+
return err
170+
}
171+
sigBytes, err := hex.DecodeString(cctx.String("sig"))
172+
if err != nil {
173+
return err
174+
}
175+
176+
pr := common.ProofRequest{
177+
Data: cid,
178+
PaymentClientID: int64(cctx.Uint64("client-id")),
179+
PaymentNonce: int64(cctx.Uint64("nonce")),
180+
PaymentCumulativeAmount: abi.NewTokenAmount(amt.Int64()),
181+
PaymentSignature: sigBytes,
182+
}
183+
184+
_, err = proofsvc.RequestProof(pr)
185+
if err != nil {
186+
return err
187+
}
188+
189+
fmt.Println("request-id:", cid.String())
190+
return nil
191+
},
192+
}
193+
194+
var proofsvcStatusCmd = &cli.Command{
195+
Name: "status",
196+
Usage: "Check proof status",
197+
Flags: []cli.Flag{
198+
&cli.StringFlag{Name: "id", Required: true},
199+
},
200+
Action: func(cctx *cli.Context) error {
201+
rcid, err := cid.Parse(cctx.String("id"))
202+
if err != nil {
203+
return err
204+
}
205+
resp, err := proofsvc.GetProofStatus(rcid)
206+
if err != nil {
207+
return err
208+
}
209+
b, err := json.MarshalIndent(resp, "", " ")
210+
if err != nil {
211+
return err
212+
}
213+
fmt.Print(string(b))
214+
return nil
215+
},
216+
}

0 commit comments

Comments
 (0)