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
2c47146a
Commit
2c47146a
authored
Oct 31, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test Challenge deployment, fix a golden minigeth
parent
31ce277a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
10 deletions
+24
-10
Challenge.sol
contracts/Challenge.sol
+5
-7
hardhat.config.js
hardhat.config.js
+1
-1
.gitignore
mipigo/.gitignore
+1
-1
minigeth.bin
mipigo/golden/minigeth.bin
+0
-0
main.go
mipsevm/main.go
+1
-1
challenge_test.js
test/challenge_test.js
+16
-0
No files found.
contracts/Challenge.sol
View file @
2c47146a
...
...
@@ -4,15 +4,15 @@ pragma solidity ^0.7.3;
import "./lib/Lib_RLPReader.sol";
interface IMIPS {
function Step(bytes32 stateHash) external
view
returns (bytes32);
function Step(bytes32 stateHash) external returns (bytes32);
function m() external pure returns (IMIPSMemory);
}
interface IMIPSMemory {
function ReadMemory(bytes32 stateHash, uint32 addr) external view returns (uint32);
function ReadBytes32(bytes32 stateHash, uint32 addr) external view returns (bytes32);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 val) external
pure
returns (bytes32);
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) external
pure
returns (bytes32);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 val) external returns (bytes32);
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) external returns (bytes32);
}
contract Challenge {
...
...
@@ -87,7 +87,6 @@ contract Challenge {
// load starting info into the input oracle
// we both agree at the beginning
// the first instruction executed in MIPS should be an access of startState
bytes32 txhash = Lib_RLPReader.readBytes32(blockNp1[4]);
bytes32 coinbase = bytes32(uint256(Lib_RLPReader.readAddress(blockNp1[2])));
bytes32 unclehash = Lib_RLPReader.readBytes32(blockNp1[1]);
...
...
@@ -98,9 +97,8 @@ contract Challenge {
bytes32 startState = GlobalStartState;
startState = mem.WriteBytes32(startState, 0xB0000000, inputHash);
// confirm the finalSystemHash asserts the state you claim (in $t0-$t7) and the machine is stopped
// you must load these proofs into MIPS before calling this
// we disagree at the end
// confirm the finalSystemHash asserts the state you claim and the machine is stopped
// you must load these trie nodes into MIPSMemory before calling this
require(mem.ReadMemory(finalSystemState, 0xC0000080) == 0x5EAD0000, "machine is not stopped in final state (PC == 0x5EAD0000)");
require(mem.ReadMemory(finalSystemState, 0xB0000800) == 0x1337f00d, "state is not outputted");
require(mem.ReadBytes32(finalSystemState, 0xB0000804) == assertionRoot, "you are claiming a different state root in machine");
...
...
hardhat.config.js
View file @
2c47146a
...
...
@@ -3,7 +3,7 @@
*/
require
(
"
@nomiclabs/hardhat-ethers
"
);
//
require("hardhat-gas-reporter");
require
(
"
hardhat-gas-reporter
"
);
module
.
exports
=
{
solidity
:
{
...
...
mipigo/.gitignore
View file @
2c47146a
...
...
@@ -3,4 +3,4 @@ go-ethereum
sysroot
test/test
minigeth
minigeth.bin
/
minigeth.bin
mipigo/golden/minigeth.bin
0 → 100644
View file @
2c47146a
File added
mipsevm/main.go
View file @
2c47146a
...
...
@@ -31,7 +31,7 @@ func main() {
})
ZeroRegisters
(
ram
)
LoadMappedFileUnicorn
(
mu
,
"../mipigo/minigeth.bin"
,
ram
,
0
)
LoadMappedFileUnicorn
(
mu
,
"../mipigo/
golden/
minigeth.bin"
,
ram
,
0
)
LoadMappedFileUnicorn
(
mu
,
fmt
.
Sprintf
(
"%s/input"
,
root
),
ram
,
0xB0000000
)
mu
.
Start
(
0
,
0x5ead0004
)
...
...
test/challenge_test.js
0 → 100644
View file @
2c47146a
const
{
expect
}
=
require
(
"
chai
"
);
describe
(
"
Challenge contract
"
,
function
()
{
beforeEach
(
async
function
()
{
// this mips can be reused for other challenges
const
MIPS
=
await
ethers
.
getContractFactory
(
"
MIPS
"
)
const
m
=
await
MIPS
.
deploy
()
const
Challenge
=
await
ethers
.
getContractFactory
(
"
Challenge
"
)
// golden minigeth.bin hash
c
=
await
Challenge
.
deploy
(
m
.
address
,
"
0x9c15aa86416a3a9d3b15188fc9f9be59626c1f83a33e5d63b58ca1bf0f8cef71
"
)
})
it
(
"
challenge contract deploys
"
,
async
function
()
{
console
.
log
(
"
Challenge deployed at
"
,
c
.
address
)
})
})
\ 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