Merge pull request #770 from szotov/solidity-vodka

Updates version of solidity in vodka
pull/507/head
David Núñez 2019-02-19 19:49:13 +01:00 committed by szotov
commit 867925ffc3
15 changed files with 857 additions and 177 deletions

View File

@ -21,7 +21,7 @@ sqlalchemy = "*"
maya = "*"
flask = "*"
# Third-Party Ethereum
py-evm = "*"
py-evm = "==0.2.0a39"
eth-tester = "*"
coincurve = "*"
web3 = "*"

814
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,58 +1,109 @@
-i https://pypi.python.org/simple
-e .
-e git+https://github.com/nucypher/py-solc.git@391b8da1a6bac5816877197bda25527c6b0b8c15#egg=py-solc
alabaster==0.7.12
ansible==2.7.7
apipkg==1.5
appdirs==1.4.3
argh==0.26.2
asn1crypto==0.24.0
atomicwrites==1.3.0
attrdict==2.0.1
attrs==18.2.0
autobahn==19.2.1
automat==0.7.0
aws-xray-sdk==0.95
babel==2.6.0
bcrypt==3.1.6
boto3==1.9.91
boto3==1.9.96
boto==2.49.0
botocore==1.12.91
botocore==1.12.96
bumpversion==0.5.3
bytestring-splitter==1.0.0a4
certifi==2018.11.29
cffi==1.11.5
cffi==1.12.0
chardet==3.0.4
click==7.0
coincurve==11.0.0
colorama==0.4.1
commonmark==0.8.1
constant-sorrow==0.1.0a8
constantly==15.1.0
coverage==4.0.3
cryptography==2.5
cytoolz==0.9.0.1 ; implementation_name == 'cpython'
dateparser==0.7.1
decorator==4.3.2
docker-pycreds==0.4.0
docker==3.7.0
docutils==0.14
ecdsa==0.13
eth-abi==2.0.0b5
eth-account==0.3.0
eth-bloom==1.0.3
eth-hash[pycryptodome,pysha3]==0.2.0
eth-keyfile==0.5.1
eth-keys==0.2.1
eth-rlp==0.1.2
eth-tester==0.1.0b37
eth-typing==2.0.0
eth-utils==1.4.1
ethpm==0.1.4a12
execnet==1.5.0
flask==1.0.2
future==0.17.1
-e git://github.com/nucypher/py-solc.git@v5.0.0-eol.0#egg=py-solc
greenlet==0.4.15
hendrix==3.2.2
hexbytes==0.1.0
humanize==0.5.1
hyperlink==18.0.0
idna==2.8
imagesize==1.1.0
incremental==17.5.0
ipfsapi==0.4.3
itsdangerous==1.1.0
jinja2==2.10
jmespath==0.9.3
jsondiff==1.1.1
jsonpickle==1.1
jsonschema==2.6.0
lru-dict==1.1.6
markupsafe==1.1.0
maya==0.6.1
mock==2.0.0
more-itertools==5.0.0
more-itertools==6.0.0
moto==1.3.7
msgpack-python==0.5.6
mypy-extensions==0.4.1
mypy==0.670
packaging==19.0
paramiko==2.4.2
parsimonious==0.8.1
pathtools==0.1.2
pbr==5.1.2
pendulum==2.0.4
pluggy==0.8.1
protobuf==3.7.0rc2
py-ecc==1.4.7
py-evm==0.2.0a39
py-geth==2.0.1
py==1.7.0
pyaml==18.11.0
pyasn1-modules==0.2.4
pyasn1==0.4.5
pychalk==2.0.1
pycparser==2.19
pycryptodome==3.7.3
pyethash==0.1.27
pygments==2.3.1
pyhamcrest==1.9.0
pynacl==1.3.0
pyopenssl==19.0.0
pyparsing==2.3.1
pysha3==1.0.2
pytest-cov==2.5.1
pytest-forked==1.0.1
pytest-ethereum==0.1.3a6
pytest-forked==1.0.2
pytest-mock==1.10.1
pytest-mypy==0.3.2
pytest-twisted==1.9
@ -62,20 +113,37 @@ python-coveralls==2.9.1
python-dateutil==2.8.0 ; python_version >= '2.7'
python-jose==2.0.2
pytz==2018.9
pytzdata==2018.9
pyyaml==4.2b4
recommonmark==0.5.0
regex==2019.2.7
requests==2.21.0
responses==0.10.5
rlp==1.1.0
s3transfer==0.2.0
semantic-version==2.6.0
sentry-sdk==0.5.2
service-identity==18.1.0
six==1.12.0
snaptime==0.2.4
snowballstemmer==1.2.1
sphinx-rtd-theme==0.4.2
sphinx-rtd-theme==0.4.3
sphinx==1.8.4
sphinxcontrib-websupport==1.1.0
sqlalchemy==1.3.0b3
toolz==0.9.0
trie==1.3.8
twisted==18.9.0
txaio==18.8.1
typed-ast==1.3.1
tzlocal==2.0.0b1
umbral==0.1.3a0
urllib3==1.24.1 ; python_version >= '3.4'
watchdog==0.9.0
web3[tester]==5.0.0a5
websocket-client==0.54.0
websockets==7.0
werkzeug==0.14.1
wrapt==1.11.1
xmltodict==0.11.0
xmltodict==0.12.0
zope.interface==4.6.0

View File

@ -115,7 +115,7 @@ contract Issuer is Upgradeable {
internal returns (uint256 amount)
{
if (currentSupply1 == totalSupply || currentSupply2 == totalSupply) {
return;
return 0;
}
uint256 currentSupply = _currentPeriod <= currentMintingPeriod ?
Math.min(currentSupply1, currentSupply2) :
@ -170,7 +170,7 @@ contract Issuer is Upgradeable {
* @notice Returns the number of tokens that can be mined
**/
function getReservedReward() public view returns (uint256) {
return totalSupply - Math.max256(currentSupply1, currentSupply2);
return totalSupply - Math.max(currentSupply1, currentSupply2);
}
function verifyState(address _testTarget) public onlyOwner {

View File

@ -153,7 +153,7 @@ contract MinersEscrow is Issuer {
**/
function setPolicyManager(PolicyManagerInterface _policyManager) external onlyOwner {
require(address(policyManager) == address(0) &&
address(_policyManager) != 0x0 &&
address(_policyManager) != address(0) &&
_policyManager.escrow() == address(this));
policyManager = _policyManager;
}
@ -162,8 +162,8 @@ contract MinersEscrow is Issuer {
* @notice Set mining adjudicator address
**/
function setMiningAdjudicator(MiningAdjudicatorInterface _miningAdjudicator) external onlyOwner {
require(address(miningAdjudicator) == 0x0 &&
address(_miningAdjudicator) != 0x0 &&
require(address(miningAdjudicator) == address(0) &&
address(_miningAdjudicator) != address(0) &&
_miningAdjudicator.escrow() == address(this));
miningAdjudicator = _miningAdjudicator;
}
@ -346,13 +346,13 @@ contract MinersEscrow is Issuer {
* @param _from Miner
* @param _value Amount of tokens to deposit
* @param _tokenContract Token contract address
* @param _extraData Amount of periods during which tokens will be locked
* @notice (param _extraData) Amount of periods during which tokens will be locked
**/
function receiveApproval(
address _from,
uint256 _value,
address _tokenContract,
bytes calldata _extraData
bytes calldata /* _extraData */
)
external
{
@ -892,11 +892,14 @@ contract MinersEscrow is Issuer {
)
internal
{
SubStakeInfo storage shortestSubStake = _info.subStakes[0];
uint16 minSubStakeLastPeriod = MAX_UINT16;
uint16 minSubStakeDuration = MAX_UINT16;
while(_penalty > 0) {
if (_shortestSubStakeIndex < MAX_SUB_STAKES) {
SubStakeInfo storage shortestSubStake = _info.subStakes[_shortestSubStakeIndex];
uint16 minSubStakeLastPeriod = getLastPeriodOfSubStake(shortestSubStake, _startPeriod);
uint16 minSubStakeDuration = minSubStakeLastPeriod.sub16(shortestSubStake.firstPeriod);
shortestSubStake = _info.subStakes[_shortestSubStakeIndex];
minSubStakeLastPeriod = getLastPeriodOfSubStake(shortestSubStake, _startPeriod);
minSubStakeDuration = minSubStakeLastPeriod.sub16(shortestSubStake.firstPeriod);
_shortestSubStakeIndex = MAX_SUB_STAKES;
} else {
(shortestSubStake, minSubStakeDuration, minSubStakeLastPeriod) =

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.3;
import "contracts/lib/UmbralDeserializer.sol";
@ -29,7 +29,7 @@ contract MiningAdjudicator is Upgradeable {
uint256 public constant UMBRAL_PARAMETER_U_YCOORD = 0x7880ed56962d7c0ae44d6f14bb53b5fe64b31ea44a41d0316f3a598778f0f936;
// used only for upgrading
bytes32 constant RESERVED_CAPSULE_AND_CFRAG_BYTES = bytes32(0);
address constant RESERVED_ADDRESS = 0x0;
address constant RESERVED_ADDRESS = address(0);
MinersEscrow public escrow;
SignatureVerifier.HashAlgorithm public hashAlgorithm;
@ -58,7 +58,7 @@ contract MiningAdjudicator is Upgradeable {
)
public
{
require(address(_escrow) != 0x0 &&
require(address(_escrow) != address(0) &&
_percentagePenaltyCoefficient != 0 &&
_rewardCoefficient != 0);
escrow = _escrow;
@ -83,15 +83,15 @@ contract MiningAdjudicator is Upgradeable {
**/
// TODO add way to slash owner of UserEscrow contract
function evaluateCFrag(
bytes _capsuleBytes,
bytes _capsuleSignatureByRequester,
bytes _capsuleSignatureByRequesterAndMiner,
bytes _cFragBytes,
bytes _cFragSignatureByMiner,
bytes _requesterPublicKey,
bytes _minerPublicKey,
bytes _minerPublicKeySignature,
bytes _preComputedData
bytes memory _capsuleBytes,
bytes memory _capsuleSignatureByRequester,
bytes memory _capsuleSignatureByRequesterAndMiner,
bytes memory _cFragBytes,
bytes memory _cFragSignatureByMiner,
bytes memory _requesterPublicKey,
bytes memory _minerPublicKey,
bytes memory _minerPublicKeySignature,
bytes memory _preComputedData
)
public
{
@ -142,7 +142,7 @@ contract MiningAdjudicator is Upgradeable {
internal returns (uint256 penalty, uint256 reward)
{
penalty = basePenalty.add(penaltyHistoryCoefficient.mul(penaltyHistory[_miner]));
penalty = Math.min256(penalty, _minerValue.div(percentagePenaltyCoefficient));
penalty = Math.min(penalty, _minerValue.div(percentagePenaltyCoefficient));
reward = penalty.div(rewardCoefficient);
// TODO add maximum condition or other overflow protection or other penalty condition
penaltyHistory[_miner] = penaltyHistory[_miner].add(1);
@ -435,7 +435,7 @@ contract MiningAdjudicator is Upgradeable {
// }
// TODO: Consider changing to internal
function extendedKeccakToBN (bytes _data) public pure returns (uint256) {
function extendedKeccakToBN (bytes memory _data) public pure returns (uint256) {
bytes32 upper;
bytes32 lower;
@ -457,15 +457,15 @@ contract MiningAdjudicator is Upgradeable {
function verifyState(address _testTarget) public onlyOwner {
require(address(delegateGet(_testTarget, "escrow()")) == address(escrow));
require(SignatureVerifier.HashAlgorithm(uint256(delegateGet(_testTarget, "hashAlgorithm()"))) == hashAlgorithm);
require(uint256(delegateGet(_testTarget, "basePenalty()")) == basePenalty);
require(uint256(delegateGet(_testTarget, "penaltyHistoryCoefficient()")) == penaltyHistoryCoefficient);
require(uint256(delegateGet(_testTarget, "percentagePenaltyCoefficient()")) == percentagePenaltyCoefficient);
require(uint256(delegateGet(_testTarget, "rewardCoefficient()")) == rewardCoefficient);
require(uint256(delegateGet(_testTarget, "penaltyHistory(address)", bytes32(RESERVED_ADDRESS))) ==
require(delegateGet(_testTarget, "basePenalty()") == basePenalty);
require(delegateGet(_testTarget, "penaltyHistoryCoefficient()") == penaltyHistoryCoefficient);
require(delegateGet(_testTarget, "percentagePenaltyCoefficient()") == percentagePenaltyCoefficient);
require(delegateGet(_testTarget, "rewardCoefficient()") == rewardCoefficient);
require(delegateGet(_testTarget, "penaltyHistory(address)", bytes32(bytes20(RESERVED_ADDRESS))) ==
penaltyHistory[RESERVED_ADDRESS]);
bytes32 evaluationCFragHash = SignatureVerifier.hash(
abi.encodePacked(RESERVED_CAPSULE_AND_CFRAG_BYTES), hashAlgorithm);
require(delegateGet(_testTarget, "evaluatedCFrags(bytes32)", evaluationCFragHash) != bytes32(0));
require(delegateGet(_testTarget, "evaluatedCFrags(bytes32)", evaluationCFragHash) != 0);
}
function finishUpgrade(address _target) public onlyOwner {

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.3;
/// @title Numerology: A Solidity library for fast ECC arithmetics using curve secp256k1
@ -227,7 +227,7 @@ library Numerology {
function doubleJacobian(uint[3] memory P) internal pure returns (uint[3] memory Q) {
uint256 z = P[2];
if (z == 0)
return;
return Q;
uint256 p = fieldOrder;
uint256 x = P[0];
uint256 _2y = mulmod(2, P[1], p);

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.3;
/**
@ -14,7 +14,7 @@ library SignatureVerifier {
* @param _hash 32 bytes message hash
* @param _signature Signature of hash - 32 bytes r + 32 bytes s + 1 byte v (could be 0, 1, 27, 28)
**/
function recover(bytes32 _hash, bytes _signature)
function recover(bytes32 _hash, bytes memory _signature)
internal
pure
returns (address)
@ -42,8 +42,8 @@ library SignatureVerifier {
* @notice Transform public key to address
* @param _publicKey secp256k1 public key
**/
function toAddress(bytes _publicKey) internal pure returns (address) {
return address(keccak256(_publicKey));
function toAddress(bytes memory _publicKey) internal pure returns (address) {
return address(uint160(uint256(keccak256(_publicKey))));
}
/**
@ -51,7 +51,7 @@ library SignatureVerifier {
* @param _message Signed message
* @param _algorithm Hashing algorithm
**/
function hash(bytes _message, HashAlgorithm _algorithm)
function hash(bytes memory _message, HashAlgorithm _algorithm)
internal
pure
returns (bytes32 result)
@ -73,7 +73,12 @@ library SignatureVerifier {
* @param _publicKey secp256k1 public key
* @param _algorithm Hashing algorithm
**/
function verify(bytes _message, bytes _signature, bytes _publicKey, HashAlgorithm _algorithm)
function verify(
bytes memory _message,
bytes memory _signature,
bytes memory _publicKey,
HashAlgorithm _algorithm
)
internal
pure
returns (bool)

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.3;
/**

View File

@ -565,7 +565,7 @@ class Bob(Character):
from nucypher.policy.models import IndisputableEvidence
return IndisputableEvidence(capsule, cfrag, ursula)
def make_wsgi_app(drone_bob, start_learning=True):
def make_wsgi_app(drone_bob, start_learning=True):
bob_control = Flask('bob-control')
drone_bob.start_learning_loop(now=start_learning)

View File

@ -441,13 +441,13 @@ class TreasureMap:
@property
def m(self):
if self._m == constants.NO_DECRYPTION_PERFORMED:
if self._m == NO_DECRYPTION_PERFORMED:
raise TypeError("The TreasureMap is probably encrypted. You must decrypt it first.")
return self._m
@property
def destinations(self):
if self._destinations == constants.NO_DECRYPTION_PERFORMED:
if self._destinations == NO_DECRYPTION_PERFORMED:
raise TypeError("The TreasureMap is probably encrypted. You must decrypt it first.")
return self._destinations

View File

@ -4,22 +4,22 @@ argh==0.26.2
asn1crypto==0.24.0
attrdict==2.0.1
attrs==18.2.0
autobahn==19.1.1
autobahn==19.2.1
automat==0.7.0
boto3==1.9.91
botocore==1.12.91
boto3==1.9.96
botocore==1.12.96
bytestring-splitter==1.0.0a4
certifi==2018.11.29
cffi==1.11.5
cffi==1.12.0
chardet==3.0.4
click==7.0
coincurve==9.0.0
coincurve==11.0.0
colorama==0.4.1
constant-sorrow==0.1.0a8
constantly==15.1.0
cryptography==2.5
cytoolz==0.9.0.1 ; implementation_name == 'cpython'
dateparser==0.7.0
dateparser==0.7.1
docutils==0.14
eth-abi==2.0.0b5
eth-account==0.3.0
@ -31,6 +31,7 @@ eth-rlp==0.1.2
eth-tester==0.1.0b37
eth-typing==2.0.0
eth-utils==1.4.1
ethpm==0.1.4a12
flask==1.0.2
hendrix==3.2.2
hexbytes==0.1.0

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.3;
import "contracts/lib/SignatureVerifier.sol";
@ -10,7 +10,7 @@ import "contracts/lib/UmbralDeserializer.sol";
**/
contract SignatureVerifierMock {
function recover(bytes32 _hash, bytes _signature)
function recover(bytes32 _hash, bytes memory _signature)
public
pure
returns (address)
@ -18,11 +18,11 @@ contract SignatureVerifierMock {
return SignatureVerifier.recover(_hash, _signature);
}
function toAddress(bytes _publicKey) public pure returns (address) {
function toAddress(bytes memory _publicKey) public pure returns (address) {
return SignatureVerifier.toAddress(_publicKey);
}
function hash(bytes _message, SignatureVerifier.HashAlgorithm _algorithm)
function hash(bytes memory _message, SignatureVerifier.HashAlgorithm _algorithm)
public
pure
returns (bytes32 result)
@ -30,7 +30,12 @@ contract SignatureVerifierMock {
return SignatureVerifier.hash(_message, _algorithm);
}
function verify(bytes _message, bytes _signature, bytes _publicKey, SignatureVerifier.HashAlgorithm _algorithm)
function verify(
bytes memory _message,
bytes memory _signature,
bytes memory _publicKey,
SignatureVerifier.HashAlgorithm _algorithm
)
public
pure
returns (bool)
@ -75,8 +80,8 @@ contract UmbralDeserializerMock {
byte pointKFragPokSign,
bytes32 pointKFragPokXCoord,
bytes32 bnSig,
bytes kFragSignature,
bytes metadata
bytes memory kFragSignature,
bytes memory metadata
)
{
UmbralDeserializer.CorrectnessProof memory proof = _proofBytes.toCorrectnessProof();
@ -105,8 +110,8 @@ contract UmbralDeserializerMock {
byte pointKFragPokSign,
bytes32 pointKFragPokXCoord,
bytes32 bnSig,
bytes kFragSignature,
bytes metadata
bytes memory kFragSignature,
bytes memory metadata
)
{
UmbralDeserializer.CapsuleFrag memory cFrag = _cFragBytes.toCapsuleFrag();

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.3;
import "contracts/MiningAdjudicator.sol";

View File

@ -259,8 +259,8 @@ def test_refund(testerchain, escrow, policy_manager):
# Create new policy
testerchain.time_travel(hours=1)
period = escrow.call().getCurrentPeriod()
tx = escrow.transact().setLastActivePeriod(period)
period = escrow.functions.getCurrentPeriod().call()
tx = escrow.functions.setLastActivePeriod(period).transact()
testerchain.wait_for_receipt(tx)
tx = policy_manager.functions.createPolicy(policy_id_2, number_of_periods, int(0.5 * rate), [node1, node2, node3]) \
.transact({'from': client, 'value': int(3 * value + 1.5 * rate), 'gas_price': 0})