Skip to content

Commit

Permalink
Merge pull request #80 from OpenSTFoundation/release-0.9
Browse files Browse the repository at this point in the history
Release v0.9.1
  • Loading branch information
jasonklein authored Dec 21, 2017
2 parents fb30598 + d1b28e4 commit 4a20d24
Show file tree
Hide file tree
Showing 58 changed files with 2,466 additions and 347 deletions.
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## OpenST-protocol v0.9.1 December 19 2017

OpenST v0.9.1 is the first release deployed on Ethereum mainnet combined with the
activation of Simple Token to power the OpenST platform. The OpenST platform
allows Ethereum smart contracts to runs faster and cheaper while leveraging
the security properties of Ethereum's Proof-of-Work. In this release we implement
the first corner stone of the protocol: the ability to stake value on Ethereum
mainnet and mint a new representation of that value on a utility chain,
effectively increasing the computational throughput of Ethereum smart contracts
by allowing parallel execution across chains.

OpenST smart contracts have been restructured to store value separately from
the logic that implements the protocol. v0.9.1 is not yet protocol complete
as the validators are whitelisted and not yet open with stake put forward on
Ethereum mainnet. However, by splitting the protocol implementation into
these two logically separate problems, we can already start working with
member companies and developers to fine-tune the APIs and the developer
experience to build mainstream applications on Ethereum.

```
Ethereum mainnet (value) | OpenST platform (utility)
---------------------------------------------------------------------
Core - - - - - - - - - - - (Core)
/ | \
/ | \
Registrar | Registrar
| | |
OpenSTValue | OpenSTUtility
\_ SimpleStake | \_ UtilityTokenAbstract
| \_ SimpleTokenPrime (base token)
| \_ BrandedToken
```

Detailed changelog:

- Generate documentation in /docs ([openst-protocol#78](https://github.com/OpenSTFoundation/openst-protocol/pull/78))
- Unit tests for Owned, OpsManaged, SafeMath (carry over from SimpleTokenSale) ([openst-protocol#73](https://github.com/OpenSTFoundation/openst-protocol/pull/73))
- Add mock ERC20 token for dryrun on Ethereum mainnet ([openst-protocol#71](https://github.com/OpenSTFoundation/openst-protocol/pull/71))
- Unit tests for protocol transfer ([openst-protocol#66](https://github.com/OpenSTFoundation/openst-protocol/pull/66))
- Integration tests for reverting stake and redemption ([openst-protocol#65](https://github.com/OpenSTFoundation/openst-protocol/pull/65))
- Bug fix revert unstaking was restricted to registrar only ([openst-protocol#64](https://github.com/OpenSTFoundation/openst-protocol/pull/64))
- Implement fallback for process staking and process redemption ([openst-protocol#60](https://github.com/OpenSTFoundation/openst-protocol/pull/60))
- Bug fix on reverted redemption allow re-use of nonce ([openst-protocol#59](https://github.com/OpenSTFoundation/openst-protocol/pull/59))
- Initiate and revoke protocol transfer ([openst-protocol#55](https://github.com/OpenSTFoundation/openst-protocol/pull/55))
- Run Truffle tests with optimised compilation to accurately measure gas usage ([openst-protocol#54](https://github.com/OpenSTFoundation/openst-protocol/pull/54))
- Integration tests improvement on event assertion ([openst-protocol#47](https://github.com/OpenSTFoundation/openst-protocol/pull/47))
- Allow reverting escrow after unlock height ([openst-protocol#46](https://github.com/OpenSTFoundation/openst-protocol/pull/46))
- Set minimal redemption accuracy ([openst-protocol#41](https://github.com/OpenSTFoundation/openst-protocol/pull/41)), ([openst-protocol#38](https://github.com/OpenSTFoundation/openst-protocol/pull/38))
- Integration test framework for staking ([openst-protocol#37](https://github.com/OpenSTFoundation/openst-protocol/pull/37))
- Increase unit test coverage for Registrar, OpenSTValue, and OpenSTUtility ([openst-protocol#35](https://github.com/OpenSTFoundation/openst-protocol/pull/35))
- Bug fix in OpenSTUtility.processRedeeming ([openst-protocol#33](https://github.com/OpenSTFoundation/openst-protocol/pull/33))
- Correct assertion bug on OpenSTValue.processStaking ([openst-protocol#18](https://github.com/OpenSTFoundation/openst-protocol/pull/18))
- Complete separation of value and logic for redemption process ([openst-protocol#11](https://github.com/OpenSTFoundation/openst-protocol/pull/11)), ([openst-protocol#12](https://github.com/OpenSTFoundation/openst-protocol/pull/12)), ([openst-protocol#13](https://github.com/OpenSTFoundation/openst-protocol/pull/13))
- Unit tests for ProtocolVersioned, SimpleStake, BrandedToken, EIP20Token, STPrime, and UtilityTokenAbstract ([openst-protocol#9](https://github.com/OpenSTFoundation/openst-protocol/pull/9))
- SimpleTokenPrime: add payable initialization function ([openst-protocol#7](https://github.com/OpenSTFoundation/openst-protocol/pull/7))
- SimpleStake: separate value from logic to enable upgrade path ([openst-protocol#5](https://github.com/OpenSTFoundation/openst-protocol/pull/1))


## OpenST-protocol [v0.9.0](https://github.com/OpenSTFoundation/openst-protocol/releases/tag/v0.9.0) November 8 2017

- update OpenST-protocol with work done on Ropsten demo ([openst-protocol#1](https://github.com/OpenSTFoundation/openst-protocol/pull/1))
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,38 @@

While OpenST 0.9 is available as-is for anyone to use, we caution that this is early stage software and under heavy ongoing development and improvement. Please report bugs and suggested improvements.

Watch demo video of milestone 1 (will take you to [https://www.youtube.com/watch?v=-SxJ8c1Xh_A](https://www.youtube.com/watch?v=-SxJ8c1Xh_A))
OpenST v0.9.1 is the first release deployed on Ethereum mainnet combined with the
activation of Simple Token to power the OpenST platform. The OpenST platform
allows Ethereum smart contracts to runs faster and cheaper while leveraging
the security properties of Ethereum's Proof-of-Work. In this release we implement
the first corner stone of the protocol: the ability to stake value on Ethereum
mainnet and mint a new representation of that value on a utility chain,
effectively increasing the computational throughput of Ethereum smart contracts
by allowing parallel execution across chains.

OpenST smart contracts have been restructured to store value separately from
the logic that implements the protocol. v0.9.1 is not yet protocol complete
as the validators are whitelisted and not yet open with stake put forward on
Ethereum mainnet. However, by splitting the protocol implementation into
these two logically separate problems, we can already start working with
member companies and developers to fine-tune the APIs and the developer
experience to build mainstream applications on Ethereum.

```
Ethereum mainnet (value) | OpenST platform (utility)
---------------------------------------------------------------------
Core - - - - - - - - - - - (Core)
/ | \
/ | \
Registrar | Registrar
| | |
OpenSTValue | OpenSTUtility
\_ SimpleStake | \_ UtilityTokenAbstract
| \_ SimpleTokenPrime (base token)
| \_ BrandedToken
```

Watch demo video of milestone 1 (v0.9.0 - will take you to [https://www.youtube.com/watch?v=-SxJ8c1Xh_A](https://www.youtube.com/watch?v=-SxJ8c1Xh_A))

[![Milestone 1 demo video](https://img.youtube.com/vi/-SxJ8c1Xh_A/0.jpg)](https://www.youtube.com/watch?v=-SxJ8c1Xh_A)

Expand Down
1 change: 1 addition & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.9.1
156 changes: 106 additions & 50 deletions contracts/OpenSTUtility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import "./STPrime.sol";
import "./STPrimeConfig.sol";
import "./BrandedToken.sol";
import "./UtilityTokenInterface.sol";
import "./ProtocolVersioned.sol";


/// @title OpenST Utility
Expand Down Expand Up @@ -71,11 +72,15 @@ contract OpenSTUtility is Hasher, OpsManaged {
address _staker, address _beneficiary, uint256 _amountST, uint256 _amountUT, uint256 _expirationHeight);
event ProcessedMint(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash, address _token,
address _staker, address _beneficiary, uint256 _amount);
event RevertedMint(bytes32 indexed _uuid, bytes32 indexed _stakingIntentHash, address _staker,
address _beneficiary, uint256 _amountUT);
event RedemptionIntentDeclared(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash,
address _token, address _redeemer, uint256 _nonce, uint256 _amount, uint256 _unlockHeight,
uint256 _chainIdValue);
event ProcessedRedemption(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash, address _token,
address _redeemer, uint256 _amount);
event RevertedRedemption(bytes32 indexed _uuid, bytes32 indexed _redemptionIntentHash,
address _redeemer, uint256 _amountUT);

/*
* Constants
Expand All @@ -102,7 +107,7 @@ contract OpenSTUtility is Hasher, OpsManaged {
uint256 public chainIdUtility;
address public registrar;
/// registered branded tokens
mapping(bytes32 /* uuid */ => RegisteredToken) public registeredTokens;
mapping(bytes32 /* uuid */ => RegisteredToken) registeredTokens;
/// name reservation is first come, first serve
mapping(bytes32 /* hashName */ => address /* requester */) public nameReservation;
/// symbol reserved for unique API routes
Expand Down Expand Up @@ -393,6 +398,36 @@ contract OpenSTUtility is Hasher, OpsManaged {
return tokenAddress;
}

function revertMinting(
bytes32 _stakingIntentHash)
external
returns (
bytes32 uuid,
address staker,
address beneficiary,
uint256 amount)
{
require(_stakingIntentHash != "");

Mint storage mint = mints[_stakingIntentHash];

// require that the mint has expired and that the staker has not
// processed the minting, ie mint has not been deleted
require(mint.expirationHeight > 0);
require(mint.expirationHeight <= block.number);

uuid = mint.uuid;
amount = mint.amount;
staker = mint.staker;
beneficiary = mint.beneficiary;

delete mints[_stakingIntentHash];

RevertedMint(uuid, _stakingIntentHash, staker, beneficiary, amount);

return (uuid, staker, beneficiary, amount);
}

/// @dev redeemer must set an allowance for the branded token with OpenSTUtility
/// as the spender so that the branded token can be taken into escrow by OpenSTUtility
/// note: for STPrime, call OpenSTUtility.redeemSTPrime as a payable function
Expand All @@ -408,7 +443,11 @@ contract OpenSTUtility is Hasher, OpsManaged {
{
require(_uuid != "");
require(_amountBT > 0);
require(_nonce > nonces[msg.sender]);
// on redemption allow the nonce to be re-used to cover for an unsuccessful
// previous redemption previously; as the nonce is strictly increasing plus
// one on the value chain; there is no gain on redeeming with the same nonce,
// only self-inflicted cost.
require(_nonce >= nonces[msg.sender]);
nonces[msg.sender] = _nonce;

// to redeem ST' one needs to send value to payable
Expand Down Expand Up @@ -455,7 +494,11 @@ contract OpenSTUtility is Hasher, OpsManaged {
bytes32 redemptionIntentHash)
{
require(msg.value > 0);
require(_nonce > nonces[msg.sender]);
// on redemption allow the nonce to be re-used to cover for an unsuccessful
// previous redemption previously; as the nonce is strictly increasing plus
// one on the value chain; there is no gain on redeeming with the same nonce,
// only self-inflicted cost.
require(_nonce >= nonces[msg.sender]);
nonces[msg.sender] = _nonce;

amountSTP = msg.value;
Expand Down Expand Up @@ -491,7 +534,14 @@ contract OpenSTUtility is Hasher, OpsManaged {
require(_redemptionIntentHash != "");

Redemption storage redemption = redemptions[_redemptionIntentHash];
require(redemption.redeemer == msg.sender);

// note: as processRedemption incurs a cost for the redeemer, we provide a fallback
// in v0.9 for registrar to process the redemption on behalf of the redeemer,
// as the redeemer could fail to process the redemption and avoid the cost of redeeming;
// this will be replaced with a signature carry-over implementation instead, where
// the signature of the intent hash suffices on value and utility chain, decoupling
// it from the transaction to processRedemption and processUnstaking
require(redemption.redeemer == msg.sender || registrar == msg.sender);

// as process redemption bears the cost there is no need to require
// the unlockHeight is not past, the same way as we do require for
Expand All @@ -514,6 +564,43 @@ contract OpenSTUtility is Hasher, OpsManaged {
return tokenAddress;
}

function revertRedemption(
bytes32 _redemptionIntentHash)
external
returns (
bytes32 uuid,
address redeemer,
uint256 amountUT)
{
require(_redemptionIntentHash != "");

Redemption storage redemption = redemptions[_redemptionIntentHash];

// require that the redemption is unlocked and exists
require(redemption.unlockHeight > 0);
require(redemption.unlockHeight <= block.number);

uuid = redemption.uuid;
amountUT = redemption.amountUT;
redeemer = redemption.redeemer;

if (redemption.uuid == uuidSTPrime) {
// transfer throws if insufficient funds
redeemer.transfer(amountUT);
} else {
EIP20Interface token = EIP20Interface(registeredTokens[redemption.uuid].token);

require(token.transfer(redemption.redeemer, redemption.amountUT));
}

delete redemptions[_redemptionIntentHash];

// fire event
RevertedRedemption(uuid, _redemptionIntentHash, redeemer, amountUT);

return (uuid, redeemer, amountUT);
}

/*
* Public view functions
*/
Expand All @@ -532,62 +619,31 @@ contract OpenSTUtility is Hasher, OpsManaged {
}

/*
* Operation functions
* Administrative functions
*/
/// @dev TODO: add events to trigger for each action
function addNameReservation(
bytes32 _hashName,
address _requester)
public
onlyAdminOrOps
returns (bool /* success */)
{
address requester = nameReservation[_hashName];
if (requester == _requester) return true;
if (requester == address(0)) {
nameReservation[_hashName] = _requester;
return true;
}
return false;
}

function setSymbolRoute(
bytes32 _hashSymbol,
address _token)
function initiateProtocolTransfer(
ProtocolVersioned _token,
address _proposedProtocol)
public
onlyAdminOrOps
returns (bool /* success */)
onlyAdmin
returns (bool)
{
address token = symbolRoute[_hashSymbol];
if (token == _token) return true;
if (token == address(0)) {
symbolRoute[_hashSymbol] = _token;
return true;
}
return false;
}
_token.initiateProtocolTransfer(_proposedProtocol);

function removeNameReservation(
bytes32 _hashName)
public
onlyAdminOrOps
returns (bool /* success */)
{
require(nameReservation[_hashName] != address(0));

delete nameReservation[_hashName];
return true;
}

function removeSymbolRoute(
bytes32 _hashSymbol)
// on the very first released version v0.9.1 there is no need
// to completeProtocolTransfer from a previous version

function revokeProtocolTransfer(
ProtocolVersioned _token)
public
onlyAdminOrOps
returns (bool /* success */)
onlyAdmin
returns (bool)
{
require(symbolRoute[_hashSymbol] != address(0));
_token.revokeProtocolTransfer();

delete symbolRoute[_hashSymbol];
return true;
}
}
6 changes: 6 additions & 0 deletions contracts/OpenSTUtilityInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ contract OpenSTUtilityInterface {
external
returns (
uint256 expirationHeight);

function processRedeeming(
bytes32 _redemptionIntentHash)
external
returns (
address tokenAddress);
}
Loading

0 comments on commit 4a20d24

Please sign in to comment.