20
20
TypeVar ,
21
21
Union ,
22
22
)
23
- from uuid import UUID
24
23
25
24
import rlp
26
25
@@ -886,9 +885,9 @@ def __call__(self, computation: 'ComputationAPI') -> None:
886
885
def as_opcode (cls : Type [T ],
887
886
logic_fn : Callable [['ComputationAPI' ], None ],
888
887
mnemonic : str ,
889
- gas_cost : int ) -> Type [ T ] :
888
+ gas_cost : int ) -> T :
890
889
"""
891
- Class factory method for turning vanilla functions into Opcode classes .
890
+ Class factory method for turning vanilla functions into Opcodes .
892
891
"""
893
892
...
894
893
@@ -1769,6 +1768,16 @@ def state_root(self) -> Hash32:
1769
1768
"""
1770
1769
...
1771
1770
1771
+ @state_root .setter
1772
+ def state_root (self , value : Hash32 ) -> None :
1773
+ """
1774
+ Force-set the state root hash.
1775
+ """
1776
+ # See: https://github.com/python/mypy/issues/4165
1777
+ # Since we can't also decorate this with abstract method we want to be
1778
+ # sure that the setter doesn't actually get used as a noop.
1779
+ raise NotImplementedError
1780
+
1772
1781
@abstractmethod
1773
1782
def has_root (self , state_root : bytes ) -> bool :
1774
1783
"""
@@ -1935,6 +1944,22 @@ def commit(self, checkpoint: JournalDBCheckpoint) -> None:
1935
1944
"""
1936
1945
...
1937
1946
1947
+ @abstractmethod
1948
+ def lock_changes (self ) -> None :
1949
+ """
1950
+ Locks in changes across all accounts' storage databases.
1951
+
1952
+ This is typically used at the end of a transaction, to make sure that
1953
+ a revert doesn't roll back through the previous transaction, and to
1954
+ be able to look up the "original" value of any account storage, where
1955
+ "original" is the beginning of a transaction (instead of the beginning
1956
+ of a block).
1957
+
1958
+ See :meth:`eth.abc.AccountStorageDatabaseAPI.lock_changes` for
1959
+ what is called on each account's storage database.
1960
+ """
1961
+ ...
1962
+
1938
1963
@abstractmethod
1939
1964
def make_state_root (self ) -> Hash32 :
1940
1965
"""
@@ -2275,7 +2300,7 @@ def account_is_empty(self, address: Address) -> bool:
2275
2300
# Access self._chaindb
2276
2301
#
2277
2302
@abstractmethod
2278
- def snapshot (self ) -> Tuple [Hash32 , UUID ]:
2303
+ def snapshot (self ) -> Tuple [Hash32 , JournalDBCheckpoint ]:
2279
2304
"""
2280
2305
Perform a full snapshot of the current state.
2281
2306
@@ -2285,14 +2310,14 @@ def snapshot(self) -> Tuple[Hash32, UUID]:
2285
2310
...
2286
2311
2287
2312
@abstractmethod
2288
- def revert (self , snapshot : Tuple [Hash32 , UUID ]) -> None :
2313
+ def revert (self , snapshot : Tuple [Hash32 , JournalDBCheckpoint ]) -> None :
2289
2314
"""
2290
2315
Revert the VM to the state at the snapshot
2291
2316
"""
2292
2317
...
2293
2318
2294
2319
@abstractmethod
2295
- def commit (self , snapshot : Tuple [Hash32 , UUID ]) -> None :
2320
+ def commit (self , snapshot : Tuple [Hash32 , JournalDBCheckpoint ]) -> None :
2296
2321
"""
2297
2322
Commit the journal to the point where the snapshot was taken. This
2298
2323
merges in any changes that were recorded since the snapshot.
@@ -2481,6 +2506,7 @@ class VirtualMachineAPI(ConfigurableAPI):
2481
2506
def __init__ (self ,
2482
2507
header : BlockHeaderAPI ,
2483
2508
chaindb : ChainDatabaseAPI ,
2509
+ chain_context : ChainContextAPI ,
2484
2510
consensus_context : ConsensusContextAPI ) -> None :
2485
2511
"""
2486
2512
Initialize the virtual machine.
0 commit comments