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

Commit 8316cfb

Browse files
authored
Merge branch 'develop' into develop
2 parents 8de4f8b + dddbbcf commit 8316cfb

25 files changed

+1223
-1746
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ before_install:
2323
- if [ -n "$SOLC_VERSION" ]; then sudo apt-get install -y tree unzip; fi
2424
install:
2525
- if [ -n "$SOLC_VERSION" ]; then /.$TRAVIS_BUILD_DIR/.travis/install_solc.sh; fi
26-
- travis_retry pip install setuptools --upgrade
26+
- travis_retry pip install pip setuptools --upgrade
2727
- travis_retry pip install tox
2828
- travis_retry pip install coverage
2929
- travis_retry pip install flake8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Contains the Transaction class, with the following methods and values:
160160

161161
### ethereum.tools.keys
162162

163-
Creates encrypted private key storaes
163+
Creates encrypted private key storages
164164

165165
* `decode_keystore_json(jsondata, password)` - returns the private key from an encrypted keystore object. NOTE: if you are loading from a file, the most convenient way to do this is `import json; key = decode_keystore_json(json.load(open('filename.json')), 'password')`
166166
* `make_keystore_json(key, pw, kdf='pbkdf2', cipher='aes-128-ctr')` - creates an encrypted keystore object for the key. Keeping `kdf` and `cipher` at their default values is recommended.

ethereum/abi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ def enc(typ, arg):
705705
else:
706706
subtyp = base, sub, arrlist[:-1]
707707
o = b''
708+
assert len(arg) == arrlist[-1][0], "Incorrect array size"
708709
for x in arg:
709710
o += enc(subtyp, x)
710711
return o

ethereum/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def calc_difficulty(parent, timestamp, config=default_config):
5656
return o
5757

5858
# Given a parent state, initialize a block with the given arguments
59-
def mk_block_from_prevstate(chain, state=None, timestamp=None, coinbase='\x35'*20, extra_data='moo ha ha says the laughing cow.'):
59+
def mk_block_from_prevstate(chain, state=None, timestamp=None, coinbase=b'\x35'*20, extra_data='moo ha ha says the laughing cow.'):
6060
state = state or chain.state
6161
blk = Block(BlockHeader())
6262
now = timestamp or chain.time()
@@ -134,7 +134,7 @@ def set_execution_results(state, block):
134134
block.header.state_root = state.trie.root_hash
135135
block.header.gas_used = state.gas_used
136136
block.header.bloom = state.bloom
137-
log.info('Block pre-sealed, %d gas used' % state.gas_used)
137+
log.debug('Block pre-sealed, %d gas used' % state.gas_used)
138138

139139
# Verify state root, receipt root, etc
140140
def verify_execution_results(state, block):

ethereum/fast_rlp.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ def consume_length_prefix(rlp, start):
6767
l = big_endian_to_int(rlp[start + 1:start + 1 + ll])
6868
return (list, l, start + 1 + ll)
6969

70+
def optimized_decode_single(x, pos):
71+
z = safe_ord(x[pos])
72+
if z < 128:
73+
return x[pos: pos + 1], 1
74+
elif z < 184:
75+
return x[pos + 1: pos + z - 127], z - 127
76+
else:
77+
ll = big_endian_to_int(x[pos + 1: pos + z - 182])
78+
return x[pos + z - 182: pos + z - 182 + ll], z - 182 + ll
79+
80+
def optimized_decode_list(rlp):
81+
o, pos = [], 0
82+
_typ, _len, pos = consume_length_prefix(rlp, pos)
83+
while pos < len(rlp):
84+
x, inc = optimized_decode_single(rlp, pos)
85+
pos += inc
86+
o.append(x)
87+
return o
88+
7089
#
7190
if sys.version_info.major == 2:
7291
encode_optimized = _encode_optimized

ethereum/messages.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ def create_contract(ext, msg):
368368
nonce = utils.encode_int(ext.get_nonce(msg.sender) - 1)
369369
msg.to = utils.mk_contract_address(msg.sender, nonce)
370370

371+
if ext.post_metropolis_hardfork() and (ext.get_nonce(msg.to) or len(ext.get_code(msg.to))):
372+
log_msg.debug('CREATING CONTRACT ON TOP OF EXISTING CONTRACT')
373+
return 0, 0, b''
374+
375+
371376
b = ext.get_balance(msg.to)
372377
if b > 0:
373378
ext.set_balance(msg.to, b)
@@ -379,9 +384,6 @@ def create_contract(ext, msg):
379384
# assert not ext.get_code(msg.to)
380385
msg.data = vm.CallData([], 0, 0)
381386
snapshot = ext.snapshot()
382-
if len(ext.get_code(msg.to)):
383-
log_msg.debug('CREATING CONTRACT ON TOP OF EXISTING CONTRACT')
384-
# return 0, 0, b''
385387

386388
ext.set_nonce(msg.to, 1 if ext.post_spurious_dragon_hardfork() else 0)
387389
res, gas, dat = _apply_msg(ext, msg, code)
@@ -393,7 +395,7 @@ def create_contract(ext, msg):
393395
# ext.set_code(msg.to, b'')
394396
return 1, gas, msg.to
395397
gcost = len(dat) * opcodes.GCONTRACTBYTE
396-
if gas >= gcost and (len(dat) <= 24576 or not ext.post_anti_dos_hardfork()):
398+
if gas >= gcost and (len(dat) <= 24576 or not ext.post_spurious_dragon_hardfork()):
397399
gas -= gcost
398400
else:
399401
dat = []

ethereum/meta.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def apply_block(state, block):
4242
def make_head_candidate(chain, txqueue=None,
4343
parent=None,
4444
timestamp=None,
45-
coinbase='\x35'*20,
45+
coinbase=b'\x35'*20,
4646
extra_data='moo ha ha says the laughing cow.',
4747
min_gasprice=0):
48-
log.info('Creating head candidate')
48+
log.debug('Creating head candidate')
4949
if parent is None:
5050
temp_state = State.from_snapshot(chain.state.to_snapshot(root_only=True), chain.env)
5151
else:
@@ -65,5 +65,5 @@ def make_head_candidate(chain, txqueue=None,
6565
cs.finalize(temp_state, blk)
6666
# Set state root, receipt root, etc
6767
set_execution_results(temp_state, blk)
68-
log.info('Created head candidate successfully')
68+
log.debug('Created head candidate successfully')
6969
return blk, temp_state

ethereum/opcodes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
0xa2: ['LOG2', 4, 0, 1125],
6262
0xa3: ['LOG3', 5, 0, 1500],
6363
0xa4: ['LOG4', 6, 0, 1875],
64-
0xe1: ['SLOADBYTES', 3, 0, 50], # to be discontinued
65-
0xe2: ['SSTOREBYTES', 3, 0, 0], # to be discontinued
66-
0xe3: ['SSIZE', 1, 1, 50], # to be discontinued
64+
#0xe1: ['SLOADBYTES', 3, 0, 50], # to be discontinued
65+
#0xe2: ['SSTOREBYTES', 3, 0, 0], # to be discontinued
66+
#0xe3: ['SSIZE', 1, 1, 50], # to be discontinued
6767
0xf0: ['CREATE', 3, 1, 32000],
6868
0xf1: ['CALL', 7, 1, 40], # 700 now
6969
0xf2: ['CALLCODE', 7, 1, 40], # 700 now
@@ -143,4 +143,3 @@
143143
CALL_CHILD_LIMIT_NUM = 63
144144
CALL_CHILD_LIMIT_DENOM = 64
145145
SUICIDE_SUPPLEMENTAL_GAS = 5000
146-

ethereum/pow/chain.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
log = get_logger('eth.chain')
25-
config_string = ':info,eth.chain:debug'
25+
config_string = ':info' #,eth.chain:debug'
2626
#config_string = ':info,eth.vm.log:trace,eth.vm.op:trace,eth.vm.stack:trace,eth.vm.exit:trace,eth.pb.msg:trace,eth.pb.tx:debug'
2727
configure_logging(config_string=config_string)
2828

@@ -250,7 +250,7 @@ def add_block(self, block):
250250
return False
251251
# Is the block being added to the head?
252252
if block.header.prevhash == self.head_hash:
253-
log.info('Adding to head', head=encode_hex(block.header.prevhash))
253+
log.info('Adding to head', head=encode_hex(block.header.prevhash[:4]))
254254
self.state.deletes = []
255255
self.state.changed = {}
256256
try:
@@ -368,13 +368,13 @@ def add_block(self, block):
368368
self.db.put(b'changed:'+block.hash, b''.join([k.encode() if isinstance(k, str) else k for k in list(changed.keys())]))
369369
print('Saved %d address change logs' % len(changed.keys()))
370370
self.db.put(b'deletes:'+block.hash, b''.join(deletes))
371-
print('Saved %d trie node deletes for block %d (%s)' % (len(deletes), block.number, utils.encode_hex(block.hash)))
371+
log.debug('Saved %d trie node deletes for block %d (%s)' % (len(deletes), block.number, utils.encode_hex(block.hash)))
372372
# Delete old junk data
373373
old_block_hash = self.get_blockhash_by_number(block.number - self.max_history)
374374
if old_block_hash:
375375
try:
376376
deletes = self.db.get(b'deletes:'+old_block_hash)
377-
print('Deleting up to %d trie nodes' % (len(deletes) // 32))
377+
log.debug('Deleting up to %d trie nodes' % (len(deletes) // 32))
378378
rdb = RefcountDB(self.db)
379379
for i in range(0, len(deletes), 32):
380380
rdb.delete(deletes[i: i+32])

ethereum/slogging.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,16 @@ def configure(config_string=None, log_json=False, log_file=None):
312312
if hasattr(logger, 'setLevel'):
313313
# Guard against `logging.PlaceHolder` instances
314314
logger.setLevel(logging.NOTSET)
315-
logger.propagate = True
315+
if config_string == ":{}".format(DEFAULT_LOGLEVEL):
316+
logger.propagate = True
317+
else:
318+
logger.propagate = True
316319

317320
for name_levels in config_string.split(','):
318321
name, _, level = name_levels.partition(':')
319322
logger = getLogger(name)
320323
logger.setLevel(level.upper())
324+
logger.propagate = True
321325

322326
configure_logging = configure
323327

0 commit comments

Comments
 (0)