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
eb492186
Commit
eb492186
authored
Oct 31, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getting not stopped in final state, need to sync regs i think
parent
f9ef6ce0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
main.go
mipsevm/main.go
+1
-0
challenge_test.js
test/challenge_test.js
+30
-5
No files found.
mipsevm/main.go
View file @
eb492186
...
@@ -32,6 +32,7 @@ func main() {
...
@@ -32,6 +32,7 @@ func main() {
ZeroRegisters
(
ram
)
ZeroRegisters
(
ram
)
LoadMappedFileUnicorn
(
mu
,
"../mipigo/golden/minigeth.bin"
,
ram
,
0
)
LoadMappedFileUnicorn
(
mu
,
"../mipigo/golden/minigeth.bin"
,
ram
,
0
)
WriteCheckpoint
(
ram
,
root
,
-
1
)
LoadMappedFileUnicorn
(
mu
,
fmt
.
Sprintf
(
"%s/input"
,
root
),
ram
,
0xB0000000
)
LoadMappedFileUnicorn
(
mu
,
fmt
.
Sprintf
(
"%s/input"
,
root
),
ram
,
0xB0000000
)
mu
.
Start
(
0
,
0x5ead0004
)
mu
.
Start
(
0
,
0x5ead0004
)
...
...
test/challenge_test.js
View file @
eb492186
const
{
expect
}
=
require
(
"
chai
"
);
const
{
expect
}
=
require
(
"
chai
"
);
const
fs
=
require
(
"
fs
"
);
// golden minigeth.bin hash
// golden minigeth.bin hash
const
goldenRoot
=
"
0x
9c15aa86416a3a9d3b15188fc9f9be59626c1f83a33e5d63b58ca1bf0f8cef71
"
const
goldenRoot
=
"
0x
ff382489fd6109b9dc2dcee3f6e202e6ae2a5e7029cd9eb4b1f931dff51ca725
"
describe
(
"
Challenge contract
"
,
function
()
{
describe
(
"
Challenge contract
"
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
// this mips can be reused for other challenges
// this mips can be reused for other challenges
const
MIPS
=
await
ethers
.
getContractFactory
(
"
MIPS
"
)
const
MIPS
=
await
ethers
.
getContractFactory
(
"
MIPS
"
)
const
m
=
await
MIPS
.
deploy
()
const
m
=
await
MIPS
.
deploy
()
mm
=
await
ethers
.
getContractAt
(
"
MIPSMemory
"
,
await
m
.
m
())
const
Challenge
=
await
ethers
.
getContractFactory
(
"
Challenge
"
)
const
Challenge
=
await
ethers
.
getContractFactory
(
"
Challenge
"
)
c
=
await
Challenge
.
deploy
(
m
.
address
,
goldenRoot
)
c
=
await
Challenge
.
deploy
(
m
.
address
,
goldenRoot
)
...
@@ -25,11 +28,33 @@ describe("Challenge contract", function () {
...
@@ -25,11 +28,33 @@ describe("Challenge contract", function () {
const
blockNp1
=
blockchain
.
_data
.
_blocksByNumber
.
get
(
blockNumberN
+
1
)
const
blockNp1
=
blockchain
.
_data
.
_blocksByNumber
.
get
(
blockNumberN
+
1
)
const
blockNp1Rlp
=
blockNp1
.
header
.
serialize
()
const
blockNp1Rlp
=
blockNp1
.
header
.
serialize
()
const
assertionRoot
=
"
0x1337133713371337133713371337133713371337133713371337133713371337
"
const
assertionRoot
=
"
0x9e0261efe4509912b8862f3d45a0cb8404b99b239247df9c55871bd3844cebbd
"
// TODO: compute a valid one of these
const
finalSystemState
=
"
0x1337133713371337133713371337133713371337133713371337133713371337
"
const
finalSystemState
=
"
0xa9aaac45d9ccaeab0b97eff2d7ce6050948f8322c869c0a8f94a0d7013c31824
"
let
startTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/eth/13284469/checkpoint_-1.json
"
))
let
finalTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/eth/13284469/checkpoint_85042025.json
"
))
await
c
.
InitiateChallenge
(
blockNumberN
,
blockNp1Rlp
,
assertionRoot
,
finalSystemState
,
1
)
while
(
1
)
{
try
{
await
c
.
InitiateChallenge
(
blockNumberN
,
blockNp1Rlp
,
assertionRoot
,
finalSystemState
,
1
)
}
catch
(
e
)
{
const
missing
=
e
.
toString
().
split
(
"
'
"
)[
1
]
if
(
missing
.
length
==
64
)
{
console
.
log
(
"
requested node
"
,
missing
)
let
node
=
startTrie
[
'
preimages
'
][
"
0x
"
+
missing
]
if
(
node
===
undefined
)
{
node
=
finalTrie
[
'
preimages
'
][
"
0x
"
+
missing
]
}
expect
(
node
).
to
.
not
.
be
.
an
(
'
undefined
'
)
const
bin
=
Uint8Array
.
from
(
Buffer
.
from
(
node
,
'
base64
'
).
toString
(
'
binary
'
),
c
=>
c
.
charCodeAt
(
0
))
await
mm
.
AddTrieNode
(
bin
)
continue
}
else
{
console
.
log
(
e
)
break
}
}
}
//const blockHeaderNp1 = getBlockRlp(await ethers.provider.getBlock(blockNumberN+1));
//const blockHeaderNp1 = getBlockRlp(await ethers.provider.getBlock(blockNumberN+1));
//console.log(blockNumberN, blockHeaderNp1);
//console.log(blockNumberN, blockHeaderNp1);
...
...
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