- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Jcb/ix tests #134
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
Jcb/ix tests #134
Changes from all commits
6e672dd
              8271d54
              d34dc40
              4b3cfbe
              216bee1
              5938727
              52431bf
              e6a212c
              63faf25
              35d1311
              685f565
              93309c8
              c9b3565
              b90fd9b
              221f352
              5aa0fc4
              ed79280
              f8d7176
              5e806e7
              37c5779
              802650e
              3de279e
              e0973fe
              6bb0129
              7e94095
              8322be7
              347268b
              efd6dbe
              32f85d3
              7ebf0ee
              2c5d0db
              a341cd3
              87fc22d
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -2,24 +2,25 @@ import Cli | |
| import Ix.Cronos | ||
| import Ix.Common | ||
| import Ix.CompileM | ||
| import Ix.TransportM | ||
| import Ix.Store | ||
| import Ix.Address | ||
| import Lean | ||
|  | ||
| -- ix store <lean file> | ||
| -- ix store get <address> | ||
| -- ix store remat <address> <address> | ||
| def runStore (p : Cli.Parsed) : IO UInt32 := do | ||
| let source : String := p.positionalArg! "source" |>.as! String | ||
| let mut cronos ← Cronos.new.clock "Lean-frontend" | ||
| Lean.setLibsPaths source | ||
| --StoreIO.toIO ensureStoreDir | ||
| let path := ⟨source⟩ | ||
| let leanEnv ← Lean.runFrontend (← IO.FS.readFile path) path | ||
| let delta := leanEnv.getDelta | ||
| cronos ← cronos.clock "Lean-frontend" | ||
| -- Start content-addressing | ||
| cronos ← cronos.clock "content-address" | ||
| let stt ← Ix.Compile.compileDeltaIO leanEnv delta | ||
| let stt ← Ix.Compile.compileEnvIO leanEnv | ||
| stt.names.forM fun name (const, meta) => do | ||
| IO.println <| s!"{name}:" | ||
| IO.println <| s!" #{const}" | ||
|  | @@ -49,13 +50,35 @@ def runGet (p : Cli.Parsed) : IO UInt32 := do | |
| IO.println <| s!"{repr const}" | ||
| return 0 | ||
|  | ||
| def runRemat (p : Cli.Parsed) : IO UInt32 := do | ||
| let cont : String := p.positionalArg! "constantAddress" |>.as! String | ||
| let meta : String := p.positionalArg! "metadataAddress" |>.as! String | ||
| let (c, m) <- IO.ofExcept $ | ||
| match Address.fromString cont, Address.fromString meta with | ||
| | .some c, .some m => .ok (c, m) | ||
| | .none, _ => .error "bad address {cont}" | ||
| | _, .none => .error "bad address {meta}" | ||
| let cont <- StoreIO.toIO (Store.readConst c) | ||
| let meta <- StoreIO.toIO (Store.readConst m) | ||
| let ix := Ix.TransportM.rematerialize cont meta | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to call this just "materialize"? In some cases, one might want to materialize something that was never read from a Lean source, like the result of some reduction by the IxVM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the analogy is with the star trek transporter https://en.wikipedia.org/wiki/Transporter_(Star_Trek), which dematerializes in one place and rematerializes somewhere else. Here dematerialization means the transformation from Ix.IR into an Ixon.Const and Ixon.Metadata. The IxVM operates just over the Ixon.Const, since the metadata isn't relevant for proving. In the proving case, we also already know the output from building the claim. If we wanted to reduce Ix constants in a non-proving context and construct new outputs, then that would need an "Ix Runtime" which should operate over Ix.IR, not Ixon, as you'd want to also transform the metadata so that the output is human readable | ||
| IO.println <| s!"{repr ix}" | ||
| return 0 | ||
|  | ||
| def storeGetCmd : Cli.Cmd := `[Cli| | ||
| get VIA runGet; | ||
| "print a store entry" | ||
| ARGS: | ||
| address : String; "Ix address" | ||
| ] | ||
|  | ||
| def storeRematCmd : Cli.Cmd := `[Cli| | ||
| remat VIA runRemat; | ||
| "print a store entry" | ||
| ARGS: | ||
| constantAddress : String; "Ix constant address" | ||
| metadataAddress : String; "Ix metadata address" | ||
| ] | ||
|  | ||
| def storeCmd : Cli.Cmd := `[Cli| | ||
| store VIA runStore; | ||
| "Interact with the Ix store" | ||
|  | @@ -67,6 +90,7 @@ def storeCmd : Cli.Cmd := `[Cli| | |
| source : String; "Source file input" | ||
|  | ||
| SUBCOMMANDS: | ||
| storeGetCmd | ||
| storeGetCmd; | ||
| storeRematCmd | ||
| ] | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.