Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaether committed Nov 17, 2017
1 parent dcc6484 commit 7d1ea6b
Show file tree
Hide file tree
Showing 37 changed files with 1,123 additions and 276 deletions.
20 changes: 19 additions & 1 deletion .devlog
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@ TODOs
-----

- Update tests to truffle
- There are 21 tests. [1.5/21]
- There are 21 tests. [8/21] but two are client tests so... [8/19]
- Theres a bug in the validateEndowment / computeEndowment function
that is causing 6 tests to fail, it needs to be figured out
- Alarm Client needs to be updated, maybe re-written in javascript / typescript so that we can compile it for browsers
- Some clean up needs to happen in the contracts so the passed args are more organized.
- Events are added to the contract so that the client can retrieve them / watch them to act accordingly.

0.9.0 (WIP)
-----------

Added:
- Full rewrite of all contracts to modern solidity syntax. [70%][still finding bugs]
- Integrate Truffle framework. [100%][rewriting tests]
- Port test suite from Populus to Truffle. [5/21]
- New API for Schedulers [100%][need further tests]
- (Add String Pool) [Needs discussion]
Removed:
- Digger.sol removed due to `EIP 150`_ making it obsolete. [done]
- All stack depth checking also obsolete due to `EIP150` removed. [done]
- SafeSendLib.sol removed due to Solidity keyword `transfer` and ``send` making it obsolete. [done]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ origContracts/
node_modules/

**/_build
alarmClient
alarmClient/*
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:17.10

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Set debconf to run non-interactively
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Install base dependencies
RUN apt-get update && apt-get install -y -q --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
git \
libssl-dev \
python \
rsync \
software-properties-common \
wget \
&& rm -rf /var/lib/apt/lists/*

ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION v8.0.0

# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH

# Install the dependencies
WORKDIR /eac
ADD . /eac
RUN cd /eac; nvm use default; npm i; npm i -g truffle@beta

CMD ["truffle" "compile"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Source code for the [Ethereum Alarm Clock service](http://www.ethereum-alarm-clo

_Tests are in the process of being ported over to ES6 JavaScript._

Status : 8 / 19 tests ported over

In progress ES6 test suite can be found in the test/ directory. Original Populus tests can be found in the tests/ directory.

To run the test suite make sure you have a testrpc running and truffle v4.0.0 installed.
Expand Down
22 changes: 0 additions & 22 deletions contracts/BlockScheduler.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/Interface/RequestFactoryInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ contract RequestFactoryInterface {
uint endowment) internal returns (bool[6]);
function createValidatedRequest(address[3] addressArgs,
uint[10] uintArgs,
bytes32 callData) payable returns (address);
bytes32 callData) public payable returns (address);
function isKnownRequest(address _address) view returns (bool);
}
8 changes: 4 additions & 4 deletions contracts/Interface/RequestTrackerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ contract RequestTrackerInterface {
function getWindowStart(address factory, address request) view returns (uint);
function getPreviousRequest(address factory, address request) view returns (address);
function getNextRequest(address factory, address request) view returns (address);
function addRequest(address request, uint startWindow) returns (bool);
function removeRequest(address request) returns (bool);
function isKnownRequest(address factory, address request) constant returns (bool);
function query(address factory, bytes2 operator, uint value) constant returns (address);
function addRequest(address request, uint startWindow) public returns (bool);
function removeRequest(address request) public returns (bool);
function isKnownRequest(address factory, address request) view returns (bool);
function query(address factory, bytes2 operator, uint value) view returns (address);
}
17 changes: 11 additions & 6 deletions contracts/Interface/SchedulerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ pragma solidity ^0.4.17;
import "contracts/Library/RequestScheduleLib.sol";
import "contracts/Library/SchedulerLib.sol";


/**
* @title SchedulerInterface
* @dev The base contract that the higher contracts: BaseScheduler, BlockScheduler and TimestampScheduler all inherit from.
*/
contract SchedulerInterface {
using SchedulerLib for SchedulerLib.FutureTransaction;

/// Public variables
address public factoryAddress;
RequestScheduleLib.TemporalUnit public temporalUnit;
address public factoryAddress; // The RequestFactory address which produces requests for this scheduler.
RequestScheduleLib.TemporalUnit public temporalUnit; // The TemporalUnit of this scheduler.

/*
* Local storage variable used to house the data for transaction
Expand All @@ -29,12 +31,15 @@ contract SchedulerInterface {
futureTransaction.resetAsBlock();
} else if (uint(temporalUnit) == 2) {
futureTransaction.resetAsTimestamp();
// } else {
// revert();
} else {
revert();
}
_;
}

// function scheduleTxSimple
// function scheduleTxFull

/*
* Full scheduling API exposing all fields.
*
Expand Down
2 changes: 1 addition & 1 deletion contracts/Interface/TransactionRequestInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract TransactionRequestInterface {
/*
* @dev Pull mechanisms for payments.
*/
function refundClaimDeposit() public returns (bool);
function refundClaimDeposit() public;
function sendDonation() public returns (bool);
function sendPayment() public returns (bool);
function sendOwnerEther() public returns (bool);
Expand Down
14 changes: 10 additions & 4 deletions contracts/IterTools.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
pragma solidity ^0.4.17;

/**
* @title IterTools
* @dev Utility library that iterates through a boolean array of length 6.
*/
library IterTools {
/*
* Return true if any of the values in the boolean array are true
* @dev Return true if all of the values in the boolean array are true.
* @param _values A boolean array of length 6.
* @return True if all values are true, False if _any_ are false.
*/
function all(bool[6] values) returns (bool) {
for (uint i = 0; i < values.length; i++) {
if (!values[i]) {
function all(bool[6] _values) returns (bool) {
for (uint i = 0; i < _values.length; i++) {
if (!_values[i]) {
return false;
}
}
Expand Down
32 changes: 18 additions & 14 deletions contracts/Library/ClaimLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ library ClaimLib {
using SafeMath for uint;

struct ClaimData {
// The address that has claimed this request
address claimedBy;
address claimedBy; // The address that has claimed this request.

// The deposit amount that was put down by the claimer.
uint claimDeposit;
uint claimDeposit; // The deposit amount that was put down by the claimer.

// TODO: add `requiredDeposit` and remove the hard-coding of the `2 *
// payment` minimum deposit size.
Expand All @@ -21,7 +19,9 @@ library ClaimLib {
}

/*
* Mark the request as being claimed
* @dev Mark the request as being claimed.
* @param self The ClaimData that is being accessed.
* @param paymentModifier The payment modifier.
*/
function claim(ClaimData storage self, uint8 paymentModifier) returns (bool) {
self.claimedBy = msg.sender;
Expand All @@ -37,25 +37,29 @@ library ClaimLib {
}

/*
* Amount that must be supplied as a deposit to claim. This is set to the
* maximum possible payment value that could be paid out by this request.
* @dev Calculates the amount that must be supplied as a deposit to claim.
* This is set to the maximum possible payment value that could be paid out by this request.
*/
function minimumDeposit(uint payment) pure returns (uint) {
function minimumDeposit(uint payment)
pure returns (uint)
{
return payment.mul(2);
}

/*
* @dev Refund the claimer deposit.
* Called in RequestLib's `cancel()` and `refundClaimDeposit()`
*/
function refundDeposit(ClaimData storage self) returns (bool) {
uint depositAmount;
function refundDeposit(ClaimData storage self)
internal returns (bool)
{
// Check that the claim deposit is non-zero.
assert( self.claimDeposit > 0 );

uint depositAmount;
depositAmount = self.claimDeposit;
if (depositAmount > 0) {
self.claimDeposit = 0;

self.claimedBy.transfer(depositAmount);
}
self.claimedBy.transfer(depositAmount);
return true;
}
}
7 changes: 3 additions & 4 deletions contracts/Library/ExecutionLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ library ExecutionLib {
function validateCallGas(uint callGas, uint EXTRA_GAS)
internal view returns (bool)
{
return true;
//callGas < CALL_GAS_CEILING(EXTRA_GAS);
}
return callGas < CALL_GAS_CEILING(EXTRA_GAS);
}

/*
* Validation: ensure that the toAddress is not set to the empty address.
*/
function validateToAddress(address toAddress)
view returns (bool)
{
return toAddress != 0x0;
return toAddress != 0x0;
}
}
26 changes: 14 additions & 12 deletions contracts/Library/PaymentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pragma solidity ^0.4.17;

import "contracts/Library/ExecutionLib.sol";
import "contracts/Library/MathLib.sol";

import "contracts/zeppelin/SafeMath.sol";

library PaymentLib {
Expand Down Expand Up @@ -148,19 +147,20 @@ library PaymentLib {
uint gasOverhead)
internal view returns (uint)
{
uint gasPrice = tx.gasprice;
return payment.add(donation)
.mul(2)
.add(_computeHelper(callGas, callValue, gasOverhead));
.add(_computeHelper(callGas, callValue, gasOverhead, gasPrice));
}

/// Was getting a stack depth error after replacing old MathLib with Zeppelin's SafeMath.
/// Added this function to fix it.
/// See for context: https://ethereum.stackexchange.com/questions/7325/stack-too-deep-try-removing-local-variables
function _computeHelper(uint _callGas, uint _callValue, uint _gasOverhead)
internal view returns (uint)
function _computeHelper(uint _callGas, uint _callValue, uint _gasOverhead, uint _gasPrice)
internal pure returns (uint)
{
return _callGas.mul(tx.gasprice).mul(2)
.add(_gasOverhead.mul(tx.gasprice).mul(2))
return _callGas.mul(_gasPrice).mul(2)
.add(_gasOverhead.mul(_gasPrice).mul(2))
.add(_callValue);
}
/*
Expand All @@ -179,11 +179,13 @@ library PaymentLib {
uint gasOverhead)
view returns (bool)
{
return true;
// return endowment >= computeEndowment(payment,
// donation,
// callGas,
// callValue,
// gasOverhead);
// return true;
Log(endowment);
return endowment >= computeEndowment(payment,
donation,
callGas,
callValue,
gasOverhead);
}
event Log(uint num);
}
Loading

0 comments on commit 7d1ea6b

Please sign in to comment.