Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2b15b4a5
Unverified
Commit
2b15b4a5
authored
Aug 07, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Add subcommand to convert from json state to binary witness
parent
58a2d894
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
witness.go
cannon/cmd/witness.go
+53
-0
main.go
cannon/main.go
+1
-0
No files found.
cannon/cmd/witness.go
0 → 100644
View file @
2b15b4a5
package
cmd
import
(
"fmt"
"os"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/urfave/cli/v2"
)
var
(
WitnessInputFlag
=
&
cli
.
PathFlag
{
Name
:
"input"
,
Usage
:
"path of input JSON state."
,
TakesFile
:
true
,
Required
:
true
,
}
WitnessOutputFlag
=
&
cli
.
PathFlag
{
Name
:
"output"
,
Usage
:
"path to write binary witness."
,
TakesFile
:
true
,
}
)
func
Witness
(
ctx
*
cli
.
Context
)
error
{
input
:=
ctx
.
Path
(
WitnessInputFlag
.
Name
)
output
:=
ctx
.
Path
(
WitnessOutputFlag
.
Name
)
state
,
err
:=
loadJSON
[
mipsevm
.
State
](
input
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid input state (%v): %w"
,
input
,
err
)
}
witness
:=
state
.
EncodeWitness
()
h
:=
crypto
.
Keccak256Hash
(
witness
)
if
output
!=
""
{
if
err
:=
os
.
WriteFile
(
output
,
witness
,
0755
);
err
!=
nil
{
return
fmt
.
Errorf
(
"writing output to %v: %w"
,
output
,
err
)
}
}
fmt
.
Println
(
h
.
Hex
())
return
nil
}
var
WitnessCommand
=
&
cli
.
Command
{
Name
:
"witness"
,
Usage
:
"Convert a Cannon JSON state into a binary witness"
,
Description
:
"Convert a Cannon JSON state into a binary witness. The hash of the witness is written to stdout"
,
Action
:
Witness
,
Flags
:
[]
cli
.
Flag
{
WitnessInputFlag
,
WitnessOutputFlag
,
},
}
cannon/main.go
View file @
2b15b4a5
...
@@ -20,6 +20,7 @@ func main() {
...
@@ -20,6 +20,7 @@ func main() {
app
.
Description
=
"MIPS Fault Proof tool"
app
.
Description
=
"MIPS Fault Proof tool"
app
.
Commands
=
[]
*
cli
.
Command
{
app
.
Commands
=
[]
*
cli
.
Command
{
cmd
.
LoadELFCommand
,
cmd
.
LoadELFCommand
,
cmd
.
WitnessCommand
,
cmd
.
RunCommand
,
cmd
.
RunCommand
,
}
}
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment