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
d0682fbb
Commit
d0682fbb
authored
Dec 08, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confirm the save worked
parent
5f9697f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
MIPSMemory.sol
contracts/MIPSMemory.sol
+6
-0
libkeccak.js
test/libkeccak.js
+6
-2
No files found.
contracts/MIPSMemory.sol
View file @
d0682fbb
...
@@ -18,6 +18,12 @@ contract MIPSMemory {
...
@@ -18,6 +18,12 @@ contract MIPSMemory {
mapping(bytes32 => Preimage) public preimage;
mapping(bytes32 => Preimage) public preimage;
function GetPreimage(bytes32 outhash, uint offset) public view returns (uint, uint32) {
uint64 data = preimage[outhash].data[offset];
require(data > 0, "offset not loaded");
return (preimage[outhash].length, uint32(data));
}
function AddPreimage(bytes calldata anything, uint offset) public {
function AddPreimage(bytes calldata anything, uint offset) public {
require(offset & 3 == 0, "offset must be 32-bit aligned");
require(offset & 3 == 0, "offset must be 32-bit aligned");
uint len = anything.length;
uint len = anything.length;
...
...
test/libkeccak.js
View file @
d0682fbb
...
@@ -40,12 +40,16 @@ describe("MIPSMemory contract", function () {
...
@@ -40,12 +40,16 @@ describe("MIPSMemory contract", function () {
await
mm
.
AddLargePreimageInit
(
4
)
await
mm
.
AddLargePreimageInit
(
4
)
let
dat
=
new
TextEncoder
(
"
utf-8
"
).
encode
(
"
hello world
"
)
let
dat
=
new
TextEncoder
(
"
utf-8
"
).
encode
(
"
hello world
"
)
let
dathash
=
keccak256
(
dat
)
const
tst
=
await
mm
.
AddLargePreimageFinal
(
dat
)
const
tst
=
await
mm
.
AddLargePreimageFinal
(
dat
)
expect
(
tst
[
0
]).
to
.
equal
(
keccak256
(
dat
)
)
expect
(
tst
[
0
]).
to
.
equal
(
dathash
)
expect
(
tst
[
1
].
toNumber
()).
to
.
equal
(
11
)
expect
(
tst
[
1
].
toNumber
()).
to
.
equal
(
11
)
expect
(
tst
[
2
]).
to
.
equal
(
0x6f20776f
)
expect
(
tst
[
2
]).
to
.
equal
(
0x6f20776f
)
console
.
log
(
tst
)
await
mm
.
AddLargePreimageFinalSaved
(
dat
)
await
mm
.
AddLargePreimageFinalSaved
(
dat
)
let
ret
=
await
mm
.
GetPreimage
(
dathash
,
4
)
expect
(
ret
[
0
].
toNumber
()).
to
.
equal
(
11
)
expect
(
ret
[
1
]).
to
.
equal
(
0x6f20776f
)
})
})
});
});
\ No newline at end of file
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