Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 245ce18

Browse files
author
Jan Xie
committed
Merge branch 'develop' into state_revamp_with_p62
2 parents 7d86e38 + aafab5b commit 245ce18

29 files changed

+187
-49
lines changed

.travis.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ language: python
22
python: 3.5
33
sudo: required
44
dist: trusty
5-
before_install:
6-
- sudo add-apt-repository -y ppa:ethereum/ethereum
7-
- sudo apt-get update
8-
- sudo apt-get install -y solc
95
env:
106
matrix:
117
- TOX_ENV=py27
@@ -15,7 +11,18 @@ env:
1511
- COVERAGE_APPEND="--append"
1612
- secure: cKbIgpTJ1yjKLBxpCEiT6IH7NShDWZUE+BvnrAfc+ujCsR6LyLJcKxFQmKnWryJCqg7fp82Ep2bF2oDKzanAROar2xDY1SFGbai42seYMaFCw53YPGJ6u3VNCcfT0rN9BWgE7el/m4fjcD6CRsZYKArNNJbMX8csRt3uXXCFLso=
1713
- secure: "QyFPrxQHd2LlNQ6zNeTFYhgPmZaOHoWuywcgn8qaSOh6PklyFxHbexkwg0bl23JvtgNEZ1mCD8j0x1/ydSdtxgCFwK9SEL0h7aYuAq+OAIa/G18OPeTJMf7ASsb2QZdfkt9reFpUnjbadzHkuv+rqqb4bFnTJBKwB2LWzHPLhWg="
14+
- SOLC_VERSION=0.4.9
15+
cache:
16+
directories:
17+
- $HOME/.bin
18+
- $HOME/solc-versions
19+
before_install:
20+
- mkdir -p $HOME/.bin
21+
- export PATH=$PATH:$HOME/.bin
22+
- if [ -n "$SOLC_VERSION" ]; then export LD_LIBRARY_PATH="$HOME/solc-versions/solc-$SOLC_VERSION"; fi
23+
- if [ -n "$SOLC_VERSION" ]; then sudo apt-get install -y tree unzip; fi
1824
install:
25+
- if [ -n "$SOLC_VERSION" ]; then /.$TRAVIS_BUILD_DIR/.travis/install_solc.sh; fi
1926
- travis_retry pip install setuptools --upgrade
2027
- travis_retry pip install tox
2128
- travis_retry pip install coverage

.travis/install_solc.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# Install solc
4+
#
5+
6+
set -e
7+
set -u
8+
9+
mkdir -p $HOME/solc-versions/solc-$SOLC_VERSION
10+
cd $HOME/solc-versions/solc-$SOLC_VERSION
11+
12+
if [ ! -f solc ]
13+
then
14+
git clone --recurse-submodules --branch v$SOLC_VERSION --depth 50 https://github.com/ethereum/solidity.git
15+
./solidity/scripts/install_deps.sh
16+
wget https://github.com/ethereum/solidity/releases/download/v$SOLC_VERSION/solidity-ubuntu-trusty.zip
17+
unzip solidity-ubuntu-trusty.zip
18+
echo "Solidity installed at $HOME/solc-versions/solc-$SOLC_VERSION/solc"
19+
tree $HOME/solc-versions/solc-$SOLC_VERSION
20+
else
21+
./solidity/scripts/install_deps.sh
22+
fi
23+
24+
if [ -f $HOME/.bin/solc ]
25+
then
26+
rm $HOME/.bin/solc
27+
fi
28+
29+
ln -s $HOME/solc-versions/solc-$SOLC_VERSION/solc $HOME/.bin/solc
30+
# Check path is correctly set up and echo version
31+
cd
32+
echo $PATH
33+
ls -al $HOME/.bin
34+
ls -al $(readlink -f $HOME/.bin/solc)
35+
solc --version

ethereum/_solidity.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class CompileError(Exception):
1717
pass
1818

1919

20+
class SolcMissing(Exception):
21+
pass
22+
23+
2024
def get_compiler_path():
2125
""" Return the path to the solc compiler.
2226
@@ -261,6 +265,34 @@ def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True, ex
261265
return solc_parse_output(output)
262266

263267

268+
def solidity_get_contract_data(all_contracts, filepath, contract_name):
269+
""" A backwards compatible method of getting the contract data out
270+
of a solc --combined-json output"""
271+
try:
272+
contract_data = all_contracts[contract_name]
273+
except:
274+
if filepath is None:
275+
filename = '<stdin>'
276+
else:
277+
_, filename = os.path.split(filepath)
278+
contract_data = all_contracts[filename + ":" + contract_name]
279+
return contract_data
280+
281+
282+
def solidity_get_contract_key(all_contracts, filepath, contract_name):
283+
""" A backwards compatible method of getting the key to the all_contracts
284+
dictionary for a particular contract"""
285+
if contract_name in all_contracts:
286+
return contract_name
287+
else:
288+
if filepath is None:
289+
filename = '<stdin>'
290+
else:
291+
_, filename = os.path.split(filepath)
292+
contract_key = filename + ":" + contract_name
293+
return contract_key if contract_key in all_contracts else None
294+
295+
264296
def compile_contract(filepath, contract_name, libraries=None, combined='bin,abi', optimize=True, extra_args=None):
265297
all_contracts = compile_file(
266298
filepath,
@@ -269,8 +301,7 @@ def compile_contract(filepath, contract_name, libraries=None, combined='bin,abi'
269301
optimize=optimize,
270302
extra_args=extra_args
271303
)
272-
273-
return all_contracts[contract_name]
304+
return solidity_get_contract_data(all_contracts, filepath, contract_name)
274305

275306

276307
def compile_last_contract(filepath, libraries=None, combined='bin,abi', optimize=True, extra_args=None):
@@ -296,7 +327,10 @@ def compile_last_contract(filepath, libraries=None, combined='bin,abi', optimize
296327

297328
def compile_code(sourcecode, libraries=None, combined='bin,abi', optimize=True, extra_args=None):
298329
args = solc_arguments(libraries=libraries, combined=combined, optimize=optimize, extra_args=extra_args)
299-
args.insert(0, get_compiler_path())
330+
compiler = get_compiler_path()
331+
if compiler is None:
332+
raise SolcMissing("solc not found")
333+
args.insert(0, compiler)
300334

301335
process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
302336
stdoutdata, stderrdata = process.communicate(input=utils.to_string(sourcecode))
@@ -335,7 +369,7 @@ def _code_or_path(sourcecode, path, contract_name, libraries, combined, extra_ar
335369
last_contract = all_contract_names[-1]
336370

337371
result = compile_code(sourcecode, libraries=libraries, combined=combined, extra_args=extra_args)
338-
return result[last_contract]
372+
return solidity_get_contract_data(result, path, last_contract)
339373

340374
@classmethod
341375
def compile(cls, code, path=None, libraries=None, contract_name='', extra_args=None):
@@ -378,7 +412,12 @@ def combined(cls, code, path=None, extra_args=None):
378412

379413
sorted_contracts = []
380414
for name in solidity_names(code):
381-
sorted_contracts.append((name[1], contracts[name[1]]))
415+
sorted_contracts.append(
416+
(
417+
name[1],
418+
solidity_get_contract_data(contracts, path, name[1])
419+
)
420+
)
382421
return sorted_contracts
383422

384423
@classmethod

ethereum/abi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# -*- coding: utf8 -*-
1+
# -*- coding: utf-8 -*-
22
from __future__ import print_function
33

44
import ast
55
import re
66
import warnings
77

88
import yaml # use yaml instead of json to get non unicode (works with ascii only data)
9-
from rlp.utils import decode_hex, encode_hex
9+
from rlp.utils import decode_hex
10+
from ethereum.utils import encode_hex
1011

1112
from ethereum import utils
1213
from ethereum.utils import (

ethereum/bloom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
component (except data) of each log entry of each transaction.
77
88
We set the bits of a 2048-bit value whose indices are given by
9-
the low order 9-bits
9+
the low order 11-bits
1010
of the first three double-bytes
1111
of the SHA3
1212
of each value.

ethereum/chain.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import time
44

55
import rlp
6-
from rlp.utils import encode_hex
76

87
from ethereum import parse_genesis_declaration
98
from ethereum.block import Block, BlockHeader, FakeHeader, BLANK_UNCLES_HASH
@@ -12,7 +11,7 @@
1211
from ethereum.state import State, dict_to_prev_header
1312
from ethereum.state_transition import apply_block, initialize, \
1413
update_block_env_variables
15-
from ethereum.utils import parse_as_bin, big_endian_to_int
14+
from ethereum.utils import encode_hex, parse_as_bin, big_endian_to_int
1615

1716
log = get_logger('eth.chain')
1817

ethereum/ethash_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import sha3 as _sha3
77
sha3_256 = lambda x: _sha3.sha3_256(x).digest()
88
sha3_512 = lambda x: _sha3.sha3_512(x).digest()
9-
from rlp.utils import decode_hex, encode_hex
9+
from rlp.utils import decode_hex
10+
from ethereum.utils import encode_hex
1011
import sys
1112

1213
WORD_BYTES = 4 # bytes in word

ethereum/ethpow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from ethereum import ethash, ethash_utils, utils
22
import time
33
import sys
4-
import sha3
54
import warnings
65
from collections import OrderedDict
6+
from ethereum import utils
77
from ethereum.slogging import get_logger
88
import rlp
99

@@ -41,7 +41,7 @@
4141

4242
def get_cache(block_number):
4343
while len(cache_seeds) <= block_number // EPOCH_LENGTH:
44-
cache_seeds.append(sha3.sha3_256(cache_seeds[-1]).digest())
44+
cache_seeds.append(utils.sha3(cache_seeds[-1]))
4545
seed = cache_seeds[block_number // EPOCH_LENGTH]
4646
if seed in cache_by_seed:
4747
c = cache_by_seed.pop(seed) # pop and append at end

ethereum/fastvm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from ethereum import opcodes
1313
import time
1414
from ethereum.slogging import get_logger
15-
from rlp.utils import encode_hex, ascii_chr
15+
from rlp.utils import ascii_chr
16+
from ethereum.utils import encode_hex
1617
from ethereum.utils import to_string
1718

1819
if sys.version_info.major == 2:

ethereum/keys.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import pbkdf2
33
import sys
44

5-
from rlp.utils import encode_hex, decode_hex
5+
from rlp.utils import decode_hex
6+
from ethereum.utils import encode_hex
67

78
try:
89
scrypt = __import__('scrypt')

0 commit comments

Comments
 (0)