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
bd158ea4
Commit
bd158ea4
authored
Nov 08, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
we responded and the bsearch went left
parent
b71f7661
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
README.md
README.md
+8
-1
Challenge.sol
contracts/Challenge.sol
+6
-0
respond.js
scripts/respond.js
+16
-5
No files found.
README.md
View file @
bd158ea4
...
@@ -63,8 +63,15 @@ minigeth/go-ethereum 1171895
...
@@ -63,8 +63,15 @@ minigeth/go-ethereum 1171895
npx hardhat run scripts/deploy.js
npx hardhat run scripts/deploy.js
BLOCK=1171895 npx hardhat run scripts/challenge.js
BLOCK=1171895 npx hardhat run scripts/challenge.js
# "attacker" is block 1171896
minigeth/go-ethereum 1171896
ID=0 npx hardhat run scripts/respond.js
(cd mipsevm && ./mipsevm 1171896 11226379)
(cd mipsevm && ./mipsevm 1171896 11226379)
ID=0 BLOCK=1171896 npx hardhat run scripts/respond.js
ID=0 BLOCK=1171896 PROPOSE=1 npx hardhat run scripts/respond.js
# "defender" is real block 1171896
(cd mipsevm && ./mipsevm 1171895 11226379)
ID=0 BLOCK=1171895 RESPOND=1 npx hardhat run scripts/respond.js
```
```
## State Oracle API
## State Oracle API
...
...
contracts/Challenge.sol
View file @
bd158ea4
...
@@ -149,6 +149,12 @@ contract Challenge {
...
@@ -149,6 +149,12 @@ contract Challenge {
return (c.L+c.R)/2;
return (c.L+c.R)/2;
}
}
function getProposedState(uint256 challengeId) view public returns (bytes32) {
Chal storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
return c.assertedState[stepNumber];
}
function ProposeState(uint256 challengeId, bytes32 riscState) external {
function ProposeState(uint256 challengeId, bytes32 riscState) external {
Chal storage c = challenges[challengeId];
Chal storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(c.challenger != address(0), "invalid challenge");
...
...
scripts/respond.js
View file @
bd158ea4
...
@@ -4,19 +4,30 @@ const { deployed, getTrieNodesForCall } = require("../scripts/lib")
...
@@ -4,19 +4,30 @@ const { deployed, getTrieNodesForCall } = require("../scripts/lib")
async
function
main
()
{
async
function
main
()
{
let
[
c
,
m
,
mm
]
=
await
deployed
()
let
[
c
,
m
,
mm
]
=
await
deployed
()
const
blockNumberN
=
parseInt
(
process
.
env
.
BLOCK
)
const
challengeId
=
parseInt
(
process
.
env
.
ID
)
const
challengeId
=
parseInt
(
process
.
env
.
ID
)
let
step
=
(
await
c
.
getStepNumber
(
challengeId
)).
toNumber
()
let
step
=
(
await
c
.
getStepNumber
(
challengeId
)).
toNumber
()
console
.
log
(
"
searching step
"
,
step
,
"
in block
"
,
blockNumberN
)
console
.
log
(
"
searching step
"
,
step
)
// see if it's proposed or not
//await c.getProposedState(challengeId)
const
blockNumberN
=
parseInt
(
process
.
env
.
BLOCK
)
let
thisTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/cannon/0_
"
+
blockNumberN
.
toString
()
+
"
/checkpoint_
"
+
step
.
toString
()
+
"
.json
"
))
let
thisTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/cannon/0_
"
+
blockNumberN
.
toString
()
+
"
/checkpoint_
"
+
step
.
toString
()
+
"
.json
"
))
const
root
=
thisTrie
[
'
root
'
]
const
root
=
thisTrie
[
'
root
'
]
console
.
log
(
"
new root
"
,
root
)
console
.
log
(
"
new root
"
,
root
)
let
ret
=
await
c
.
ProposeState
(
challengeId
,
root
)
if
(
process
.
env
.
PROPOSE
==
"
1
"
)
{
let
receipt
=
await
ret
.
wait
()
let
ret
=
await
c
.
ProposeState
(
challengeId
,
root
)
console
.
log
(
receipt
)
let
receipt
=
await
ret
.
wait
()
console
.
log
(
receipt
)
}
if
(
process
.
env
.
RESPOND
==
"
1
"
)
{
let
ret
=
await
c
.
RespondState
(
challengeId
,
root
)
let
receipt
=
await
ret
.
wait
()
console
.
log
(
receipt
)
}
}
}
main
()
main
()
...
...
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