Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit a8b3719

Browse files
committed
Clean up
1 parent 4f0b493 commit a8b3719

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

evm/vm/base.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def import_block(self, block):
163163

164164
def mine_block(self, *args, **kwargs):
165165
"""
166-
Mine the current block. Proxies to the current block's mine method.
167-
See example with FrontierBlock. :meth:`~evm.vm.forks.frontier.blocks.FrontierBlock.mine`
166+
Mine the current block. Proxies to self.pack_block method.
168167
"""
169168
block = self.block
170169
self.pack_block(block, *args, **kwargs)
@@ -460,18 +459,18 @@ def get_state_class(cls):
460459

461460
return cls._state_class
462461

463-
def get_state(self, chaindb=None, block_header=None, prev_headers=None):
462+
def get_state(self, chaindb=None, block_header=None):
464463
"""Return state object
465464
"""
466465
if chaindb is None:
467466
chaindb = self.chaindb
468-
if block_header is None: # TODO: remove
467+
if block_header is None:
469468
block_header = self.block.header
470-
if prev_headers is None:
471-
prev_headers = self.get_prev_headers(
472-
last_block_hash=self.block.header.parent_hash,
473-
db=self.chaindb,
474-
)
469+
470+
prev_headers = self.get_prev_headers(
471+
last_block_hash=self.block.header.parent_hash,
472+
db=self.chaindb,
473+
)
475474
receipts = self.block.get_receipts(self.chaindb)
476475
return self.get_state_class()(
477476
chaindb,

evm/vm/forks/byzantium/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77

88

99
EIP649_BLOCK_REWARD = 3 * denoms.ether
10+
11+
EIP658_TRANSACTION_STATUS_CODE_FAILURE = b'\x00'
12+
EIP658_TRANSACTION_STATUS_CODE_SUCCESS = b'\x01'

evm/vm/forks/byzantium/vm_state.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from evm.vm.forks.spurious_dragon.vm_state import SpuriousDragonVMState
66

77
from .computation import ByzantiumComputation
8+
from .constants import (
9+
EIP658_TRANSACTION_STATUS_CODE_FAILURE,
10+
EIP658_TRANSACTION_STATUS_CODE_SUCCESS,
11+
)
812

913

1014
class ByzantiumVMState(SpuriousDragonVMState):
@@ -13,8 +17,13 @@ class ByzantiumVMState(SpuriousDragonVMState):
1317
def make_receipt(self, transaction, computation):
1418
old_receipt = _make_frontier_receipt(self, transaction, computation)
1519

20+
if computation.is_error:
21+
state_root = EIP658_TRANSACTION_STATUS_CODE_FAILURE
22+
else:
23+
state_root = EIP658_TRANSACTION_STATUS_CODE_SUCCESS
24+
1625
receipt = Receipt(
17-
state_root=b'' if computation.is_error else b'\x01',
26+
state_root=state_root,
1827
gas_used=old_receipt.gas_used,
1928
logs=old_receipt.logs,
2029
)

evm/vm/forks/frontier/vm_state.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ def validate_block(self, block):
248248
)
249249
)
250250

251-
# XXX: Should these and some other checks be moved into
252-
# VM.validate_block(), as they apply to all block flavours?
253251
if len(block.uncles) > MAX_UNCLES:
254252
raise ValidationError(
255253
"Blocks may have a maximum of {0} uncles. Found "

evm/vm_state.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ def difficulty(self):
7777
def gas_limit(self):
7878
return self.block_header.gas_limit
7979

80-
#
81-
# chaindb
82-
#
83-
# @property
84-
# def chaindb(self):
85-
# return self._chaindb
86-
87-
def set_chaindb(self, db):
88-
self._chaindb = db
89-
9080
#
9181
# state_db
9282
#
@@ -132,8 +122,8 @@ def revert(self, snapshot):
132122
with self.state_db() as state_db:
133123
# first revert the database state root.
134124
state_db.root_hash = state_root
135-
# now roll the underlying database back
136125

126+
# now roll the underlying database back
137127
self._chaindb.revert(checkpoint_id)
138128

139129
def commit(self, snapshot):
@@ -205,11 +195,9 @@ def apply_transaction(
205195
"""
206196
Apply transaction to the given block
207197
208-
:param vm_state: the VMState object
209198
:param transaction: the transaction need to be applied
210199
:param block: the block which the transaction applies on
211-
:param is_stateless: if is_stateless, call VMState.add_transactionto set block
212-
:type vm_state: VMState
200+
:param is_stateless: if is_stateless, call self.add_transaction to set block
213201
:type transaction: Transaction
214202
:type block: Block
215203
:type is_stateless: bool
@@ -234,16 +222,15 @@ def apply_transaction(
234222

235223
def add_transaction(self, transaction, computation, block):
236224
"""
237-
Add a transaction to the given block and save the block data into chaindb.
225+
Add a transaction to the given block and
226+
return `trie_data` to store the transaction data in chaindb in VM layer.
238227
239228
Update the bloom_filter, transaction trie and receipt trie roots, bloom_filter,
240229
bloom, and used_gas of the block.
241230
242-
:param vm_state: the VMState object
243231
:param transaction: the executed transaction
244232
:param computation: the Computation object with executed result
245233
:param block: the Block which the transaction is added in
246-
:type vm_state: VMState
247234
:type transaction: Transaction
248235
:type computation: Computation
249236
:type block: Block

0 commit comments

Comments
 (0)