@@ -10,6 +10,7 @@ import (
1010 "time"
1111
1212 "worldcoin/gnark-mbu/logging"
13+ "worldcoin/gnark-mbu/poseidon_tree"
1314 "worldcoin/gnark-mbu/prover"
1415 "worldcoin/gnark-mbu/server"
1516
@@ -226,7 +227,7 @@ func main() {
226227
227228 if mode == server .InsertionMode {
228229 params := prover.InsertionParameters {}
229- tree := NewTree (treeDepth )
230+ tree := poseidon_tree . NewTree (treeDepth )
230231
231232 params .StartIndex = 0
232233 params .PreRoot = tree .Root ()
@@ -241,7 +242,7 @@ func main() {
241242 r , err = json .Marshal (& params )
242243 } else if mode == server .DeletionMode {
243244 params := prover.DeletionParameters {}
244- tree := NewTree (treeDepth )
245+ tree := poseidon_tree . NewTree (treeDepth )
245246
246247 params .DeletionIndices = make ([]uint32 , batchSize )
247248 params .IdComms = make ([]big.Int , batchSize )
@@ -320,6 +321,73 @@ func main() {
320321 return nil
321322 },
322323 },
324+ {
325+ Name : "start-from-s3" ,
326+ Flags : []cli.Flag {
327+ & cli.StringFlag {Name : "mode" , Usage : "insertion/deletion" , EnvVars : []string {"MTB_MODE" }, DefaultText : "insertion" },
328+ & cli.BoolFlag {Name : "json-logging" , Usage : "enable JSON logging" , Required : false },
329+ & cli.StringFlag {Name : "prover-address" , Usage : "address for the prover server" , Value : "localhost:3001" , Required : false },
330+ & cli.StringFlag {Name : "metrics-address" , Usage : "address for the metrics server" , Value : "localhost:9998" , Required : false },
331+ & cli.StringFlag {Name : "s3-region" , Usage : "s3 region of bucket" , EnvVars : []string {"S3_REGION" }, DefaultText : "us-east1" },
332+ & cli.StringFlag {Name : "s3-bucket" , Usage : "s3 bucket name" , EnvVars : []string {"S3_BUCKET" }, Required : true },
333+ & cli.StringFlag {Name : "s3-object-key" , Usage : "s3 object key (path)" , EnvVars : []string {"S3_OBJECT_KEY" }, Required : true },
334+ & cli.IntFlag {Name : "s3-concurrency" , Usage : "number of concurrent connections to download from s3" , EnvVars : []string {"S3_CONCURRENCY" }, DefaultText : "8" },
335+ & cli.Int64Flag {Name : "s3-part-mibs" , Usage : "size of part to download from s3" , EnvVars : []string {"S3_PART_MIBS" }, DefaultText : "64" },
336+ },
337+ Action : func (context * cli.Context ) error {
338+ if context .Bool ("json-logging" ) {
339+ logging .SetJSONOutput ()
340+ }
341+ region := context .String ("s3-region" )
342+ bucket := context .String ("s3-bucket" )
343+ objectKey := context .String ("s3-object-key" )
344+ concurrency := context .Int ("s3-concurrency" )
345+ partMibs := context .Int64 ("s3-part-mibs" )
346+ mode := context .String ("mode" )
347+
348+ if mode != server .DeletionMode && mode != server .InsertionMode {
349+ return fmt .Errorf ("invalid mode: %s" , mode )
350+ }
351+
352+ logging .Logger ().
353+ Info ().
354+ Str ("region" , region ).
355+ Str ("bucket" , bucket ).
356+ Str ("objectKey" , objectKey ).
357+ Str ("objectKey" , objectKey ).
358+ Int ("concurrency" , concurrency ).
359+ Int64 ("partMibs" , partMibs ).
360+ Msg ("Loading proving system from S3" )
361+
362+ start := time .Now ()
363+ ps , err := prover .ReadSystemFromS3 (region , bucket , objectKey , concurrency , partMibs )
364+ if err != nil {
365+ return err
366+ }
367+ duration := time .Since (start )
368+ logging .Logger ().
369+ Info ().
370+ Uint32 ("treeDepth" , ps .TreeDepth ).
371+ Uint32 ("batchSize" , ps .BatchSize ).
372+ Dur ("duration" , duration ).
373+ Msg ("Proving system loaded" )
374+
375+ config := server.Config {
376+ ProverAddress : context .String ("prover-address" ),
377+ MetricsAddress : context .String ("metrics-address" ),
378+ Mode : mode ,
379+ }
380+ instance := server .Run (& config , ps )
381+ sigint := make (chan os.Signal , 1 )
382+ signal .Notify (sigint , os .Interrupt )
383+ <- sigint
384+ logging .Logger ().Info ().Msg ("Received sigint, shutting down" )
385+ instance .RequestStop ()
386+ logging .Logger ().Info ().Msg ("Waiting for server to close" )
387+ instance .AwaitStop ()
388+ return nil
389+ },
390+ },
323391 {
324392 Name : "prove" ,
325393 Flags : []cli.Flag {
0 commit comments