Skip to content

Truffle 5 #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"useWSL": true,
"preLaunchTask": "ganache",
"args": ["test"],
"program": "${workspaceFolder}/node_modules/.bin/truffle"
}
]
}
19 changes: 19 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "ganache",
"isBackground": true,
"type": "npm",
"options": {
"shell": {
"args": ["-i", "-c"]
}
},
"script": "ganache",
"problemMatcher": []
},
]
}
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ The whitepaper for BeakerOS is contained in a separate repository:

## Installation

You will need Nodejs and Yarn Installed.
You will need Nodejs Installed.

* Get yarn: `npm -g i yarn`
* Install: `yarn`
* Install: `npm i`

## Testing

Run `yarn test`.
Run `npm test`.
4 changes: 2 additions & 2 deletions beakerlib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CallCap extends Cap {
// Format the capability values into the values that will be stored in the
// kernel. Must be defined for all subclasses
keyValues() {
const val = Array.from(this.keys.map(x=>web3.fromAscii(x.padEnd(32,'\0'))));
const val = this.keys.map(x=> web3.utils.utf8ToHex(x).padEnd(66,'0'))
return val;
}
}
Expand All @@ -138,7 +138,7 @@ class RegisterCap extends Cap {
// Format the capability values into the values that will be stored in the
// kernel. Must be defined for all subclasses
keyValues() {
const val = Array.from(this.keys.map(x=>web3.fromAscii(x.padEnd(32,'\0'))));
const val = this.keys.map(x=> web3.utils.utf8ToHex(x.padEnd(32,'\0')))
return val;
}
}
Expand Down
79 changes: 0 additions & 79 deletions contracts/BeakerContract.sol

This file was deleted.

3 changes: 2 additions & 1 deletion contracts/Kernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ contract Kernel is Factory {
}
} else {
assembly {
// Revert with an error code
// Revert with an error code due to an incorrect number
// of topics
mstore(0,44)
revert(0,0x20)
}
Expand Down
56 changes: 44 additions & 12 deletions contracts/test/valid/SysCallTest.sol
Original file line number Diff line number Diff line change
@@ -1,26 +1,58 @@
pragma solidity ^0.4.17;

import "../../BeakerContract.sol";

contract SysCallTest is BeakerContract {
contract SysCallTest {
function S() public {
uint256 n = read(0x8000);
write(0x8000,n+1);
assembly {
if iszero(eq(sload(0x8000),add(n,1))) {
mstore(0xd,2200)
// First get the original value from storage
let orig_value := sload(0x8000)
// First set up the input data (at memory location 0x0)
// The write call is 0x-07
mstore(0x0,0x07)
// The capability index is 0x-01
mstore(0x20,0x01)
// The storage location we want is 0x8000
mstore(0x40,0x8000)
// The value we want to store
mstore(0x60,add(orig_value,1))
// clear the output buffer
mstore(0x80,0)
// "in_offset" is at 31, because we only want the last byte of type
// "in_size" is 97 because it is 1+32+32+32
// we will store the result at 0x80 and it will be 32 bytes
if iszero(delegatecall(gas, caller, 31, 97, 0x80, 0x20)) {
mstore(0xd,add(2200,mload(0x80)))
revert(0xd,0x20)
}
mstore(0x80,0)
return(0x80,0)
mstore(0xd,sload(0x8000))
if iszero(eq(sload(0x8000),add(orig_value,1))) {
mstore(0xd,add(2200,mload(0x80)))
revert(0xd,0x20)
}
return(0x80,0x20)
}
}

function() public {
write(0x8000,356);
assembly {
mstore(0x9999999,123)
revert(0x9999999,0x20)
// First get the original value from storage
let orig_value := sload(0x8000)
// First set up the input data (at memory location 0x0)
// The write call is 0x-07
mstore(0x0,0x07)
// The capability index is 0x-01
mstore(0x20,0x01)
// The storage location we want is 0x8000
mstore(0x40,0x8000)
// The value we want to store
mstore(0x60,356)
// "in_offset" is at 31, because we only want the last byte of type
// "in_size" is 97 because it is 1+32+32+32
// we will store the result at 0x80 and it will be 32 bytes
if iszero(delegatecall(gas, caller, 31, 97, 0x80, 0x20)) {
mstore(0xd,add(2500,mload(0x80)))
revert(0xd,0x20)
}
return(0x80, 0x20)
}
}
}
Loading