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
3f4ba769
Commit
3f4ba769
authored
Jul 21, 2023
by
inphi
Committed by
clabby
Jul 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: Update pre-image input for local keys
parent
33690dab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
evm.go
cannon/mipsevm/evm.go
+1
-0
witness.go
cannon/mipsevm/witness.go
+5
-7
No files found.
cannon/mipsevm/evm.go
View file @
3f4ba769
...
...
@@ -27,6 +27,7 @@ var (
StepBytes4
=
crypto
.
Keccak256
([]
byte
(
"step(bytes,bytes)"
))[
:
4
]
CheatBytes4
=
crypto
.
Keccak256
([]
byte
(
"cheat(uint256,bytes32,bytes32,uint256)"
))[
:
4
]
LoadKeccak256PreimagePartBytes4
=
crypto
.
Keccak256
([]
byte
(
"loadKeccak256PreimagePart(uint256,bytes)"
))[
:
4
]
LoadLocalDataBytes4
=
crypto
.
Keccak256
([]
byte
(
"loadLocalData(uint256,bytes32,uint8)"
))[
:
4
]
)
// LoadContracts loads the Cannon contracts, from op-bindings package
...
...
cannon/mipsevm/witness.go
View file @
3f4ba769
...
...
@@ -49,16 +49,14 @@ func (wit *StepWitness) EncodePreimageOracleInput() ([]byte, error) {
switch
preimage
.
KeyType
(
wit
.
PreimageKey
[
0
])
{
case
preimage
.
LocalKeyType
:
// We have no on-chain form of preparing the bootstrap pre-images onchain yet.
// So instead we cheat them in.
// In production usage there should be an on-chain contract that exposes this,
// rather than going through the global keccak256 oracle.
if
len
(
wit
.
PreimageValue
)
>
32
+
8
{
return
nil
,
fmt
.
Errorf
(
"local pre-image exceeds maximum size of 32 bytes with key 0x%x"
,
wit
.
PreimageKey
)
}
var
input
[]
byte
input
=
append
(
input
,
CheatBytes4
...
)
input
=
append
(
input
,
uint32ToBytes32
(
wit
.
PreimageOffset
)
...
)
input
=
append
(
input
,
LoadLocalDataBytes4
...
)
input
=
append
(
input
,
wit
.
PreimageKey
[
:
]
...
)
var
tmp
[
32
]
byte
copy
(
tmp
[
:
],
wit
.
PreimageValue
[
wit
.
PreimageOffset
:
])
copy
(
tmp
[
:
],
wit
.
PreimageValue
[
8
:
])
input
=
append
(
input
,
tmp
[
:
]
...
)
input
=
append
(
input
,
uint32ToBytes32
(
uint32
(
len
(
wit
.
PreimageValue
))
-
8
)
...
)
// Note: we can pad calldata to 32 byte multiple, but don't strictly have to
...
...
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